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

Peiming Liu via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 09:47:44 PDT 2025


================
@@ -228,6 +228,24 @@ MachineInstr *TargetInstrInfo::commuteInstructionImpl(MachineInstr &MI,
     SubReg0 = SubReg1;
   }
 
+  // For a case like this:
+  //   %0.sub = INST %0.sub(tied), %1.sub, implicit-def %0
+  // we need to update the implicit-def after commuting to result in:
+  //   %1.sub = INST %1.sub(tied), %0.sub, implicit-def %1
+  SmallVector<unsigned> UpdateImplicitDefIdx;
+  if (HasDef && MI.hasImplicitDef() && MI.getOperand(0).getReg() != Reg0) {
+    const TargetRegisterInfo *TRI =
+        MI.getMF()->getSubtarget().getRegisterInfo();
+    Register OrigReg0 = MI.getOperand(0).getReg();
----------------
PeimingLiu wrote:

Okay, Can I get a stamp? I will remove the check!

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


More information about the llvm-commits mailing list