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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 07:54:06 PDT 2026


================
@@ -953,6 +953,12 @@ 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.findRegisterDefOperand(AMDGPU::SCC, /*TRI=*/nullptr)
----------------
arsenm wrote:

allImplicitDefsAreDead or hardcode the scc index 

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


More information about the llvm-commits mailing list