https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116879
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tnfchris at gcc dot gnu.org Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Mine. The first correct PHI is created by slpeel_tree_duplicate_loop_to_edge_cfg here: /* For the main loop exit preserve the LC PHI nodes. For vectorization we need them to continue or finalize reductions. Since we do not copy the loop exit blocks we have to materialize PHIs at the new destination before redirecting edges. */ for (auto gsi_from = gsi_start_phis (loop_exit->dest); !gsi_end_p (gsi_from); gsi_next (&gsi_from)) { tree res = gimple_phi_result (*gsi_from); create_phi_node (copy_ssa_name (res), new_preheader); and the 2nd broken one later by tree new_res = copy_ssa_name (gimple_phi_result (from_phi)); gphi *lcssa_phi = create_phi_node (new_res, new_preheader); SET_PHI_ARG_DEF_ON_EDGE (lcssa_phi, loop_exit, new_arg); adjust_phi_and_debug_stmts (to_phi, loop_entry, new_res); where the issue is I think that we have a stray virtual PHI in the loop and if-conversion doesn't do anything to this loop but we accept it now with code in the "latch" where the latch now consists of two blocks. When we want to support general uncounted loops we probably have to merge some of the multi/single-edge handling code in peeling again. I'll fix this up in vect_analyze_loop_form now and for GCC 14.