Skip to content

Commit e092395

Browse files
committed
[NVPTX] Prevent fptrunc of v2f32 from being folded into store
1 parent 9b6777c commit e092395

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
731731
setTruncStoreAction(MVT::f32, MVT::bf16, Expand);
732732
setTruncStoreAction(MVT::f64, MVT::bf16, Expand);
733733
setTruncStoreAction(MVT::f64, MVT::f32, Expand);
734+
setTruncStoreAction(MVT::v2f32, MVT::v2f16, Expand);
735+
setTruncStoreAction(MVT::v2f32, MVT::v2bf16, Expand);
734736

735737
// PTX does not support load / store predicate registers
736738
setOperationAction(ISD::LOAD, MVT::i1, Custom);

llvm/test/CodeGen/NVPTX/f32x2-instructions.ll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,12 +1960,14 @@ define <2 x float> @test_uitofp_2xi32_to_2xfloat(<2 x i32> %a) #0 {
19601960
define void @test_trunc_to_v2bf16(<2 x float> %a, ptr %p) {
19611961
; CHECK-LABEL: test_trunc_to_v2bf16(
19621962
; CHECK: {
1963+
; CHECK-NEXT: .reg .b32 %r<4>;
19631964
; CHECK-NEXT: .reg .b64 %rd<3>;
19641965
; CHECK-EMPTY:
19651966
; CHECK-NEXT: // %bb.0:
19661967
; CHECK-NEXT: ld.param.b64 %rd2, [test_trunc_to_v2bf16_param_1];
1967-
; CHECK-NEXT: ld.param.b64 %rd1, [test_trunc_to_v2bf16_param_0];
1968-
; CHECK-NEXT: st.b32 [%rd2], %rd1;
1968+
; CHECK-NEXT: ld.param.v2.b32 {%r1, %r2}, [test_trunc_to_v2bf16_param_0];
1969+
; CHECK-NEXT: cvt.rn.bf16x2.f32 %r3, %r2, %r1;
1970+
; CHECK-NEXT: st.b32 [%rd2], %r3;
19691971
; CHECK-NEXT: ret;
19701972
%trunc = fptrunc <2 x float> %a to <2 x bfloat>
19711973
store <2 x bfloat> %trunc, ptr %p
@@ -1975,12 +1977,14 @@ define void @test_trunc_to_v2bf16(<2 x float> %a, ptr %p) {
19751977
define void @test_trunc_to_v2f16(<2 x float> %a, ptr %p) {
19761978
; CHECK-LABEL: test_trunc_to_v2f16(
19771979
; CHECK: {
1980+
; CHECK-NEXT: .reg .b32 %r<4>;
19781981
; CHECK-NEXT: .reg .b64 %rd<3>;
19791982
; CHECK-EMPTY:
19801983
; CHECK-NEXT: // %bb.0:
19811984
; CHECK-NEXT: ld.param.b64 %rd2, [test_trunc_to_v2f16_param_1];
1982-
; CHECK-NEXT: ld.param.b64 %rd1, [test_trunc_to_v2f16_param_0];
1983-
; CHECK-NEXT: st.b32 [%rd2], %rd1;
1985+
; CHECK-NEXT: ld.param.v2.b32 {%r1, %r2}, [test_trunc_to_v2f16_param_0];
1986+
; CHECK-NEXT: cvt.rn.f16x2.f32 %r3, %r2, %r1;
1987+
; CHECK-NEXT: st.b32 [%rd2], %r3;
19841988
; CHECK-NEXT: ret;
19851989
%trunc = fptrunc <2 x float> %a to <2 x half>
19861990
store <2 x half> %trunc, ptr %p

0 commit comments

Comments
 (0)