https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109342
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:1d0ba4467dd9cad11eb9ff547442e3ce6292b892 commit r13-6942-g1d0ba4467dd9cad11eb9ff547442e3ce6292b892 Author: Richard Biener <rguent...@suse.de> Date: Thu Mar 30 11:32:19 2023 +0200 tree-optimization/109342 - wrong code with edge equivalences in VN The following testcase shows a problem in how we query valitity for equivalences on edges when the edge is a backedge and thus refering to a block thats later in the iteration order we use for VN. That causes the dominated_by_p_w_unex helper to look at edge executable state that's not yet computed and thus still at optimistic not executable state. The following makes sure to use a plain dominance check in these cases. PR tree-optimization/109342 * tree-ssa-sccvn.cc (vn_nary_op_get_predicated_value): New overload for edge. When that edge is a backedge use dominated_by_p directly. * g++.dg/torture/pr109342.C: New testcase.