[llvm] [AMDGPU] Add commute for some VOP3 inst (PR #121326)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 3 01:57:42 PST 2025


================
@@ -2785,6 +2799,9 @@ MachineInstr *SIInstrInfo::commuteInstructionImpl(MachineInstr &MI, bool NewMI,
   } else if (!Src0.isReg() && Src1.isReg()) {
     if (isOperandLegal(MI, Src1Idx, &Src0))
       CommutedMI = swapRegAndNonRegOperand(MI, Src1, Src0);
+  } else if (isInlineConstant(Src0) && isInlineConstant(Src1)) {
+    if (isOperandLegal(MI, Src1Idx, &Src0))
----------------
Shoreshen wrote:

BTW, the isOperandLegal check may also be necessary, because some of the operand type cannot use inline constant, e.g. second operand of `V_ADD_CO_U32_e32`

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


More information about the llvm-commits mailing list