https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90594
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Created attachment 46417 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46417&action=edit prerequesite This is the prerequesite for getting rid of the seprate pass doing final value replacement. It makes DCE elide LC PHI nodes if there's a DEF to eliminate. Note the patch isn't 100% finished because it doesn't yet deal with the undefined overflow issue (easy to add) and I've left out cost considerations (also to incerase coverage for testing). The factoring is also not actually factoring (well, if the pass vanishes...). As followup we'd remove the SCEV cprop pass. There are still other passes that could consider doing final value replacement more aggressively of course (unvectorizable/parallelizable reductions, IVOPTs, etc.). So the chance is that with the DCE approach mainly aiming at pattern detection and loop removal we'd regress elsewhere. I've looked at mitigating the bad decision done for the testcase in this bug in the final value replacement pass itself but doing so doesn't look possible w/o replicating DCE.