https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124034
--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
t.c:8:22: note: init: stmt relevant? length_12 = length_15 + -1;
t.c:8:22: note: vec_stmt_relevant_p: used out of loop.
t.c:8:22: note: vect_is_simple_use: operand length_15 = PHI <length_12(7),
length_8(D)(2)>, type of def: induction
t.c:8:22: note: vec_stmt_relevant_p: stmt live but not relevant.
t.c:8:22: note: mark relevant 1, live 1: length_12 = length_15 + -1;
we do vectorize this stmt, but we fail to code generate the live operation.
That's because we restrict SLP discovery for it to vect_used_only_live, but
it's vect_used_in_scope. This is because of the backedge use in the
induction PHI. We usually exempt that but...
/* We are also not interested in uses on loop PHI backedges that are
inductions. Otherwise we'll needlessly vectorize the IV increment
and cause hybrid SLP for SLP inductions. */
else if (gimple_code (stmt_vinfo->stmt) == GIMPLE_PHI
&& STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_induction_def
&& (PHI_ARG_DEF_FROM_EDGE (stmt_vinfo->stmt,
loop_latch_edge (bb->loop_father))
== use)
&& (!LOOP_VINFO_EARLY_BREAKS (loop_vinfo)
|| (gimple_bb (stmt_vinfo->stmt)
!= LOOP_VINFO_LOOP (loop_vinfo)->header)))
there's this early break condition ...
Removing that fixes the testcase w/o regressing gcc.dg/vect/vect-pr123983.c.
A patch to restore the removed replacement from r16-7324 in a more targeted
way does (regress that testcase). Such replacement _is_ supposed to come
from vectorizable_live_operation.
I'm testing removal of the above, the fallback solution is to make the
SLP discovery guard less strict.