https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108574
--- Comment #6 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:7ac3e69e311351b70407d7f87a0169c4d463e57b commit r13-5492-g7ac3e69e311351b70407d7f87a0169c4d463e57b Author: Richard Biener <rguent...@suse.de> Date: Mon Jan 30 09:25:23 2023 +0100 tree-optimization/108574 - wrong-code with PRE PHI node processing The PR108523 was too optimistic in replacing the same value with an equivalence from a possibly not taken edge. The following rectifies this and instead refrains from using the equivalence in the problematic cases. PR tree-optimization/108574 * tree-ssa-sccvn.cc (visit_phi): Instead of swapping sameval and def, ignore the equivalence if there's the danger of oscillating between two values. * gcc.dg/torture/pr108574-1.c: New testcase. * gcc.dg/torture/pr108574-2.c: Likewise. * gcc.dg/torture/pr108574-3.c: Likewise.