[llvm] [AMDGPU] Do not commute DPP instructions with a non-identity dpp_ctrl (PR #218393)

Diana Picus via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 01:18:33 PDT 2026


================
@@ -2898,11 +2898,21 @@ bool SIInstrInfo::isLegalToSwap(const MachineInstr &MI, unsigned OpIdx0,
   return isImmOperandLegal(MI, OpIdx1, MO0);
 }
 
+bool SIInstrInfo::isCommutableDPP(const MachineInstr &MI) const {
+  if (!isDPP(MI))
+    return true;
----------------
rovka wrote:

It's confusing for a helper called "isCommutableDPP" to return true for something that's not a DPP at all. It sounds more like the kind of helper that should only be called on instructions that we already know are DPP.

If you want to get away with just one call in the users, it might be better to invert it:
```
// False if it's not a DPP at all, or if we can commute it.
if (isNonCommutableDPP(MI))
  return early;
```

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


More information about the llvm-commits mailing list