[llvm] set i1 kill (PR #124028)
Konstantina Mitropoulou via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 22 16:00:53 PST 2025
https://github.com/kmitropoulou created https://github.com/llvm/llvm-project/pull/124028
- **[NFC] Use GCNPat instead of Pat.**
- **[AMDGPU] Always emit SI_KILL_I1_PSEUDO for uniform floating point branches.**
>From a20f999cbc2ce115355983a806ba5f65adfcf09d Mon Sep 17 00:00:00 2001
From: Konstantina Mitropoulou <KonstantinaMitropoulou at amd.com>
Date: Wed, 22 Jan 2025 14:30:06 -0800
Subject: [PATCH 1/2] [NFC] Use GCNPat instead of Pat.
---
llvm/lib/Target/AMDGPU/SIInstructions.td | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td
index 40a20fa9cb15ea..be3adae7dc905e 100644
--- a/llvm/lib/Target/AMDGPU/SIInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -1053,39 +1053,39 @@ 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 <
+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
>;
>From 5eadc3d548a288f8ae59e1ae8db434441034e95a Mon Sep 17 00:00:00 2001
From: Konstantina Mitropoulou <KonstantinaMitropoulou at amd.com>
Date: Wed, 22 Jan 2025 15:13:00 -0800
Subject: [PATCH 2/2] [AMDGPU] Always emit SI_KILL_I1_PSEUDO for uniform
floating point branches.
---
llvm/lib/Target/AMDGPU/AMDGPU.td | 3 +++
llvm/lib/Target/AMDGPU/SIInstructions.td | 1 +
2 files changed, 4 insertions(+)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td
index 7ad6720b8001af..6439149d801f6b 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 be3adae7dc905e..ae3d20bcfb3aaf 100644
--- a/llvm/lib/Target/AMDGPU/SIInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -1063,6 +1063,7 @@ def : GCNPat <
(SI_KILL_I1_PSEUDO SCSrc_i1:$src, -1)
>;
+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))
More information about the llvm-commits
mailing list