Skip to content

Commit c007c46

Browse files
authored
[NVPTX] Support BFloat Store Parameter (#137074)
Before this patch, the instruction selector assumed that if the Memory Type is not {f16, v2f16, f32, f64} then the node type must be a ConstantSDNode when in fact if the memory type is bf16 then the node type is ConstantFPSDNode.
1 parent 4ed8bfd commit c007c46

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ bool NVPTXDAGToDAGISel::tryStoreParam(SDNode *N) {
18681868
case 1: {
18691869
MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
18701870
SDValue Imm = Ops[0];
1871-
if (MemTy != MVT::f16 && MemTy != MVT::v2f16 &&
1871+
if (MemTy != MVT::f16 && MemTy != MVT::bf16 &&
18721872
(isa<ConstantSDNode>(Imm) || isa<ConstantFPSDNode>(Imm))) {
18731873
// Convert immediate to target constant
18741874
if (MemTy == MVT::f32 || MemTy == MVT::f64) {

llvm/test/CodeGen/NVPTX/st-param-imm.ll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,3 +2000,27 @@ declare void @call_v4_i8(%struct.char4 alignstack(4))
20002000
declare void @call_v4_i16(%struct.short4 alignstack(8))
20012001
declare void @call_v4_i32(%struct.int4 alignstack(16))
20022002
declare void @call_v4_f32(%struct.float4 alignstack(16))
2003+
2004+
define void @st_param_bfloat() {
2005+
; CHECK-LABEL: st_param_bfloat(
2006+
; CHECK: {
2007+
; CHECK-NEXT: .reg .b16 %rs<2>;
2008+
; CHECK-EMPTY:
2009+
; CHECK-NEXT:// %bb.0:
2010+
; CHECK-NEXT: mov.b16 %rs1, 0x4100;
2011+
; CHECK-NEXT: { // callseq 83, 0
2012+
; CHECK-NEXT: .param .align 2 .b8 param0[2];
2013+
; CHECK-NEXT: st.param.b16 [param0], %rs1;
2014+
; CHECK-NEXT: call.uni
2015+
; CHECK-NEXT: call_bfloat,
2016+
; CHECK-NEXT: (
2017+
; CHECK-NEXT: param0
2018+
; CHECK-NEXT: );
2019+
; CHECK-NEXT: } // callseq 83
2020+
; CHECK-NEXT: ret;
2021+
%five = bitcast i16 16640 to bfloat
2022+
call void @call_bfloat(bfloat %five)
2023+
ret void
2024+
}
2025+
2026+
declare void @call_bfloat(bfloat)

0 commit comments

Comments
 (0)