[llvm] [AMDGPU] Use s_cmovk_i32 instead of s_cselect_b32 when applicable (PR #135232)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 04:52:28 PDT 2025


================
@@ -883,6 +883,50 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
         }
       }
 
+      // Try to use S_CMOVK_I32 in place of S_CSELECT_B32
+      if (MI.getOpcode() == AMDGPU::S_CSELECT_B32) {
+        const MachineOperand *Dest = &MI.getOperand(0);
+        MachineOperand *Src0 = &MI.getOperand(1);
+        MachineOperand *Src1 = &MI.getOperand(2);
+        // Must be exactly one Immediate
+        if (!(Src0->isReg() ^ Src1->isReg()))
----------------
jayfoad wrote:

```suggestion
        if (Src0->isReg() == Src1->isReg())
```

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


More information about the llvm-commits mailing list