]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/124034 - remove early-break special-casing of inductions
authorRichard Biener <rguenther@suse.de>
Mon, 9 Feb 2026 09:53:01 +0000 (10:53 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 9 Feb 2026 11:57:05 +0000 (12:57 +0100)
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.

gcc/testsuite/gcc.dg/vect/vect-early-break_142-pr124034.c [new file with mode: 0644]
gcc/tree-vect-stmts.cc

diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_142-pr124034.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_142-pr124034.c
new file mode 100644 (file)
index 0000000..4834544
--- /dev/null
@@ -0,0 +1,31 @@
+/* { 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();
+}
index e7d6b4c123afe541b4adb5ec96e2f3dcea125bc3..77f6d7a639aeea7d0b12e9769fc3b7425ba9c391 100644 (file)
@@ -644,10 +644,7 @@ process_use (stmt_vec_info stmt_vinfo, tree use, loop_vec_info loop_vinfo,
           && 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,