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

Guy David via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 30 06:23:19 PDT 2025


guy-david wrote:

> > > > The insertion point of COPY isn't always optimal and could eventually lead to a worse block layout, see the regression test in the first commit.
> > > > This change affects many architectures but the amount of total instructions in the test cases seems too be slightly lower.
> > > 
> > > 
> > > The COPY you reuse is dead (right?) so why is reusing it any better than inserting a new one and allowing the dead one to be DCEd? (Or, why wasn't the dead COPY already DCEd before we got to this point?)
> > 
> > 
> > That's an unfortunate edge case for the problem I was trying to solve, for which I added a regression test in #146320. In the original issue there were no dead instructions.
> 
> No, I mean in your patch DefMI is a COPY which defines SrcReg which has no uses, therefore it's a dead COPY, right?

The user is PHI node which is being removed in flight.

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


More information about the llvm-commits mailing list