[llvm] [AMDGPU] Delete redundant s_or_b32 (PR #165261)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 08:54:35 PST 2025


================
@@ -10689,6 +10691,33 @@ bool SIInstrInfo::optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
     if (!optimizeSCC(Def, &CmpInstr, RI))
       return false;
 
+    // If s_or_b32 result, sY, is unused (i.e. it is effectively a 64-bit
+    // s_cmp_lg of a register pair) and the inputs are the hi and lo-halves of a
+    // 64-bit foldableSelect then delete s_or_b32 in the sequence:
+    //    sX = s_cselect_b64 (non-zero imm), 0
+    //    sLo = copy sX.sub0
+    //    sHi = copy sX.sub1
+    //    sY = s_or_b32 sLo, sHi
----------------
LU-JOHN wrote:

s_or_b32 may still be alive because it defines scc.  This optimization ensures that the scc def is redundant because it is already available after the s_cselect_b64.

https://github.com/llvm/llvm-project/pull/165261


More information about the llvm-commits mailing list