After recent improvements to how we deal with early-break requirements
of induction variable updates we no longer need to force induction
latch defs relevant. This in turn makes only-live defs visible to
SLP discovery, resolving the miscompilation in this PR.
PR tree-optimization/124034
* tree-vect-stmts.cc (process_use): Never force induction
latch defs relevant when doing early break vectorization.
* gcc.dg/vect/vect-early-break_142-pr124034.c: New testcase.
--- /dev/null
+/* { dg-add-options vect_early_break } */
+
+#include "tree-vect.h"
+
+__attribute__((noipa))
+static
+long
+memeqbyte (char byte, void *data, long length)
+{
+ char *p = data;
+ for (long i = 0; i < 16; i++, length--)
+ {
+ if (length == 0)
+ return 0;
+ if (p[i] != byte)
+ return 0;
+ }
+ return length;
+}
+
+#define n 16
+
+int
+main ()
+{
+ char iov[n];
+ check_vect ();
+ __builtin_memset (iov, 'x', n);
+ if (memeqbyte('x', iov, n))
+ __builtin_abort();
+}
&& 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)))
+ == use))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,