diff options
author | Konstantina Mitropoulou <44334539+kmitropoulou@users.noreply.github.com> | 2025-01-29 09:00:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-29 09:00:40 -0800 |
commit | 9adc99bcc5645b7446262e89f59c9ff797c8d09b (patch) | |
tree | 5bad6d9f7e653e2d44949c478de87b4e6eafea19 | |
parent | e0054e984cac39322afa32a6e68fc794f0081f49 (diff) | |
download | llvm-9adc99bcc5645b7446262e89f59c9ff797c8d09b.zip llvm-9adc99bcc5645b7446262e89f59c9ff797c8d09b.tar.gz llvm-9adc99bcc5645b7446262e89f59c9ff797c8d09b.tar.bz2 |
[AMDGPU] Always emit SI_KILL_I1_PSEUDO for uniform floating point branches. (#124028)
- **[NFC] Use GCNPat instead of Pat.**
- **[AMDGPU] Always emit SI_KILL_I1_PSEUDO for uniform floating point
branches.**
---------
Co-authored-by: Konstantina Mitropoulou <KonstantinaMitropoulou@amd.com>
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPU.td | 3 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIInstructions.td | 15 | ||||
-rw-r--r-- | llvm/test/CodeGen/AMDGPU/set_kill_i1_for_floation_point_comparison.ll | 41 |
3 files changed, 52 insertions, 7 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td index 7ad6720..6439149 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPU.td +++ b/llvm/lib/Target/AMDGPU/AMDGPU.td @@ -2498,6 +2498,9 @@ def HasNotMADIntraFwdBug : Predicate<"!Subtarget->hasMADIntraFwdBug()">; def HasSALUFloatInsts : Predicate<"Subtarget->hasSALUFloatInsts()">, AssemblerPredicate<(all_of FeatureSALUFloatInsts)>; +def NotHasSALUFloatInsts : Predicate<"!Subtarget->hasSALUFloatInsts()">, + AssemblerPredicate<(all_of (not FeatureSALUFloatInsts))>; + def HasPseudoScalarTrans : Predicate<"Subtarget->hasPseudoScalarTrans()">, AssemblerPredicate<(all_of FeaturePseudoScalarTrans)>; diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td index aa81d9b..5af4698 100644 --- a/llvm/lib/Target/AMDGPU/SIInstructions.td +++ b/llvm/lib/Target/AMDGPU/SIInstructions.td @@ -1053,39 +1053,40 @@ def : GCNPat< (SI_ELSE $src, $target) >; -def : Pat < +def : GCNPat < (int_amdgcn_kill i1:$src), (SI_KILL_I1_PSEUDO SCSrc_i1:$src, 0) >; -def : Pat < +def : GCNPat < (int_amdgcn_kill (i1 (not i1:$src))), (SI_KILL_I1_PSEUDO SCSrc_i1:$src, -1) >; -def : Pat < +let SubtargetPredicate = NotHasSALUFloatInsts in +def : GCNPat < (int_amdgcn_kill (i1 (setcc f32:$src, InlineImmFP32:$imm, cond:$cond))), (SI_KILL_F32_COND_IMM_PSEUDO VSrc_b32:$src, (bitcast_fpimm_to_i32 $imm), (cond_as_i32imm $cond)) >; -def : Pat < +def : GCNPat < (int_amdgcn_wqm_demote i1:$src), (SI_DEMOTE_I1 SCSrc_i1:$src, 0) >; -def : Pat < +def : GCNPat < (int_amdgcn_wqm_demote (i1 (not i1:$src))), (SI_DEMOTE_I1 SCSrc_i1:$src, -1) >; // TODO: we could add more variants for other types of conditionals -def : Pat < +def : GCNPat < (i64 (int_amdgcn_icmp i1:$src, (i1 0), (i32 33))), (COPY $src) // Return the SGPRs representing i1 src >; -def : Pat < +def : GCNPat < (i32 (int_amdgcn_icmp i1:$src, (i1 0), (i32 33))), (COPY $src) // Return the SGPRs representing i1 src >; diff --git a/llvm/test/CodeGen/AMDGPU/set_kill_i1_for_floation_point_comparison.ll b/llvm/test/CodeGen/AMDGPU/set_kill_i1_for_floation_point_comparison.ll new file mode 100644 index 0000000..5f101c3 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/set_kill_i1_for_floation_point_comparison.ll @@ -0,0 +1,41 @@ +; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 +; RUN: llc -mtriple=amdgcn -mcpu=gfx1200 -verify-machineinstrs -stop-after=amdgpu-isel < %s 2>&1 | FileCheck %s + +define amdgpu_ps void @_amdgpu_ps_main() { + ; CHECK-LABEL: name: _amdgpu_ps_main + ; CHECK: bb.0.entry: + ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000) + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0 + ; CHECK-NEXT: [[REG_SEQUENCE:%[0-9]+]]:sgpr_128 = REG_SEQUENCE [[S_MOV_B32_]], %subreg.sub0, [[S_MOV_B32_]], %subreg.sub1, [[S_MOV_B32_]], %subreg.sub2, [[S_MOV_B32_]], %subreg.sub3 + ; CHECK-NEXT: [[S_BUFFER_LOAD_DWORD_IMM:%[0-9]+]]:sreg_32_xm0_xexec = S_BUFFER_LOAD_DWORD_IMM killed [[REG_SEQUENCE]], 0, 0 :: (dereferenceable invariant load (s32)) + ; CHECK-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sgpr_32 = S_MOV_B32 0 + ; CHECK-NEXT: nofpexcept S_CMP_NLT_F32 [[S_BUFFER_LOAD_DWORD_IMM]], [[S_MOV_B32_1]], implicit-def $scc, implicit $mode + ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32_xm0_xexec = COPY $scc + ; CHECK-NEXT: SI_KILL_I1_PSEUDO killed [[COPY]], 0, implicit-def dead $exec, implicit-def dead $scc, implicit $exec + ; CHECK-NEXT: nofpexcept S_CMP_LT_F32 [[S_BUFFER_LOAD_DWORD_IMM]], [[S_MOV_B32_1]], implicit-def $scc, implicit $mode + ; CHECK-NEXT: S_CBRANCH_SCC1 %bb.2, implicit $scc + ; CHECK-NEXT: S_BRANCH %bb.1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: bb.1.bb1: + ; CHECK-NEXT: successors: %bb.2(0x80000000) + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: bb.2.bb2: + ; CHECK-NEXT: S_ENDPGM 0 +entry: + %i = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> zeroinitializer, i32 0, i32 0) + %i1 = bitcast i32 %i to float + %i2 = fcmp uge float %i1, 0.000000e+00 + call void @llvm.amdgcn.kill(i1 %i2) + br i1 %i2, label %bb1, label %bb2 + +bb1: ; preds = %entry + %i3 = call i64 @llvm.amdgcn.s.getpc() + %i4 = and i64 %i3, 1 + %i5 = inttoptr i64 %i4 to ptr addrspace(4) + %i6 = getelementptr i8, ptr addrspace(4) %i5, i64 32 + br label %bb2 + +bb2: ; preds = %bb, %entry + ret void +} |