[llvm] [AMDGPU] Preserve live SCC when shrinking disjoint S_OR_B32 to S_ADDK_I32 (PR #228025)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 04:03:14 PDT 2026


================
@@ -953,6 +953,11 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
         }
         if (Src0->isReg() && Src0->getReg() == Dest->getReg()) {
           if (Src1->isImm() && isKImmOperand(MI, *Src1)) {
+            // S_OR_B32 sets SCC to (result != 0), but S_ADDK_I32 sets it to
+            // signed overflow, so only shrink the OR when SCC is dead.
+            if (MI.getOpcode() == AMDGPU::S_OR_B32 &&
+                !MI.allImplicitDefsAreDead())
----------------
jayfoad wrote:

Maybe check this around line 934 instead, where we already check if the OR is suitable for shrinking?

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


More information about the llvm-commits mailing list