[llvm] [LLVM] Insert IMPLICIT_DEF for a register sequence if any operand is undef (PR #158000)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 08:18:50 PDT 2025


================
@@ -1998,9 +1999,17 @@ void TwoAddressInstructionImpl::eliminateRegSequence(
                   .valueOut();
     }
   }
-
+  for (unsigned i = 1, e = MI.getNumOperands(); i < e; i += 2)
+    if (MI.getOperand(i).isReg() && MI.getOperand(i).isUndef()) {
+      // Insert the IMPLICIT_DEF on dst register.
+      MachineInstr *DefMI =
+          BuildMI(*MI.getParent(), MI, MI.getDebugLoc(),
+                  TII->get(TargetOpcode::IMPLICIT_DEF), DstReg);
----------------
arsenm wrote:

Yes, it could. But it's also important to treat sub registers consistently 

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


More information about the llvm-commits mailing list