[llvm] [PHIElimination] Reuse existing COPY in predecessor basic block (PR #131837)

Mikael Holmén via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 21:55:10 PDT 2025


================
@@ -581,6 +581,15 @@ void PHIEliminationImpl::LowerPHINode(MachineBasicBlock &MBB,
       continue;
     }
 
+    // Reuse an existing copy in the block if possible.
+    if (MachineInstr *DefMI = MRI->getUniqueVRegDef(SrcReg)) {
+      if (DefMI->isCopy() && DefMI->getParent() == &opBlock &&
+          MRI->use_empty(SrcReg)) {
----------------
mikaelholmen wrote:

@guy-david 
Can you please do take care of this?

We don't want the presence of debug instructions to affect code generation.

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


More information about the llvm-commits mailing list