[llvm] [CodeGen] Do not use subsituteRegister to update implicit def (PR #148068)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 05:29:00 PDT 2025


================
@@ -238,15 +256,10 @@ MachineInstr *TargetInstrInfo::commuteInstructionImpl(MachineInstr &MI,
   }
 
   if (HasDef) {
-    // Use `substituteRegister` so that for a case like this:
-    //   %0.sub = INST %0.sub(tied), %1.sub, implicit-def %0
-    // the implicit-def is also updated, to result in:
-    //   %1.sub = INST %1.sub(tied), %0.sub, implicit-def %1
-    const TargetRegisterInfo &TRI =
-        *MI.getMF()->getSubtarget().getRegisterInfo();
-    Register FromReg = CommutedMI->getOperand(0).getReg();
-    CommutedMI->substituteRegister(FromReg, Reg0, /*SubRegIdx=*/0, TRI);
----------------
sdesmalen-arm wrote:

I don't think there's an issue with `substituteRegister` itself, it's just that for instructions like the one added in the test, we only want to swap the two commutative operands, not all operands with that register.

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


More information about the llvm-commits mailing list