https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122599
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <[email protected]>: https://gcc.gnu.org/g:77e10b47f25d05d51a187822fe6a8366a6d68d67 commit r16-5093-g77e10b47f25d05d51a187822fe6a8366a6d68d67 Author: Andrew Pinski <[email protected]> Date: Fri Nov 7 14:01:33 2025 -0800 sccp: Fix order of removal of phi (again) [PR122599] This time we are gimplifying the expression and call fold_stmt during the gimplification (which is fine) but since we removed the phi and the expression references ssa names in the phi indirectly, things just fall over inside the ranger. This moves the removal of the phi until gimplification happens as it might refer back to the ssa name that the phi defines. Pushed as obvious after bootstrap test on x86_64-linux-gnu. PR tree-optimization/122599 gcc/ChangeLog: * tree-scalar-evolution.cc (final_value_replacement_loop): Move the removal of the phi until after the gimplification of the final value expression. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr122599-1.c: New test. Signed-off-by: Andrew Pinski <[email protected]>
