https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129064
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:a0627765c5626f320f26f80ea6aba3c6fb7f19d1 commit r17-6759-ga0627765c5626f320f26f80ea6aba3c6fb7f19d1 Author: Richard Biener <[email protected]> Date: Thu Nov 26 14:28:40 2026 +0100 tree-optimization/129064 - value-number PHIs of a block in parallel When a PHI cycle is equivalent to two other PHI cycles in the same block, value-numbering can fail to terminate, oscillating between CSEing the PHIs of the cycle to a different, inconsistent mix of the candidate cycles. The cause is that process_bb value-numbers PHIs sequentially and commits each new value immediately. A PHI argument flowing in over a backedge that is the result of a PHI visited earlier in the same block then sees its new value while one that is the result of a PHI visited later sees the old one. Depending on the order of the PHIs this lets one PHI cycle advance a step ahead of an equivalent one, so equivalent cycles are not discovered. Instead value-number all PHIs of a block based on the previous values of their arguments and commit the new values only after all PHIs have been visited, matching the parallel execution semantics of PHIs and the handling of the backedge check in do_rpo_vn_1. PR tree-optimization/129064 * tree-ssa-sccvn.cc (set_ssa_val_to): Adjust checking assert to allow a not yet committed value of a PHI in the same block. (process_bb): Value-number PHIs in parallel, committing new values after visiting all PHIs of the block. * gcc.dg/tree-ssa/ssa-fre-120.c: New testcase.
