https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46555
--- Comment #18 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Richard Biener from comment #1) > Yep. That's one optimization that was removed (out-of-SSA did that) and > we thought of doing this reverse mergephi optimization as a separate pass > before expansion. make_forwarders_with_degenerate_phis in tree-ssa-dce.cc does basically (if I read the code correctly) that which was added by r12-5301-g045206450386 for PR 102880 which is why I am seeing it fixed for GCC 12 at -O2. And the reason why -O1 I still see the old PHI behavior.