[llvm] [IPSCCP] Do not attempt `tryToReplaceWithConstant` if may break invariants (PR #102820)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 01:27:19 PDT 2024


antoniofrighetto wrote:

> > > It's even more obvious when you consider that the returned constant may just be a constant integer/float rather than a global. That can open up all kinds of optimizations, and is also something where rematerialization is more likely to be profitable.
> > 
> > 
> > Makes sense. Could reverting the constant replacement be an option, once DCE and friends have used SCCP results and have run, and we know materializing the constant turned out to be not profitable (as it is the case in #102791)? So, possibly somewhere in SelectionDAG?
> 
> At least in principle, yes, we could do that. It may be easier to handle in CGP rather than SDAG, esp. for cross-block cases.

Right, cleaning up the IR for this in CGP may be more amenable – thanks for the suggestion!

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


More information about the llvm-commits mailing list