https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84552
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Probably related to us doing SCEV analysis w/o updating SSA form but follow_copies_to_constant and degenerate_phi_result not honoring that. The following would fix this: Index: gcc/tree-scalar-evolution.c =================================================================== --- gcc/tree-scalar-evolution.c (revision 258030) +++ gcc/tree-scalar-evolution.c (working copy) @@ -280,6 +280,7 @@ along with GCC; see the file COPYING3. #include "params.h" #include "tree-ssa-propagate.h" #include "gimple-fold.h" +#include "tree-into-ssa.h" static tree analyze_scalar_evolution_1 (struct loop *, tree); static tree analyze_scalar_evolution_for_address_of (struct loop *loop, @@ -1545,7 +1546,9 @@ follow_copies_to_constant (tree var) gimple *def = SSA_NAME_DEF_STMT (res); if (gphi *phi = dyn_cast <gphi *> (def)) { - if (tree rhs = degenerate_phi_result (phi)) + if (name_registered_for_update_p (gimple_phi_result (phi))) + break; + else if (tree rhs = degenerate_phi_result (phi)) res = rhs; else break;