]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/117307 - STMT_VINFO_SLP_VECT_ONLY mis-computation
authorRichard Biener <rguenther@suse.de>
Mon, 28 Oct 2024 08:52:08 +0000 (09:52 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 17 Jan 2025 08:53:34 +0000 (09:53 +0100)
STMT_VINFO_SLP_VECT_ONLY isn't properly computed as union of all
group members and when the group is later split due to duplicates
not all sub-groups inherit the flag.

PR tree-optimization/117307
* tree-vect-data-refs.cc (vect_analyze_data_ref_accesses):
Properly compute STMT_VINFO_SLP_VECT_ONLY.  Set it on all
parts of a split group.

* gcc.dg/vect/pr117307.c: New testcase.

(cherry picked from commit 19722308a286d9a00eead8ac82b948da8c4ca38b)

gcc/testsuite/gcc.dg/vect/pr117307.c [new file with mode: 0644]
gcc/tree-vect-data-refs.cc

diff --git a/gcc/testsuite/gcc.dg/vect/pr117307.c b/gcc/testsuite/gcc.dg/vect/pr117307.c
new file mode 100644 (file)
index 0000000..dc853d6
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=x86-64-v4" { target { x86_64-*-* i?86-*-* } } } */
+
+int a;
+float *b, *c;
+float d;
+void e() {
+  for (; a; a++) {
+    if (d) {
+      c[0] = b[0];
+      c[1] = b[1];
+    } else if (b[1])
+      c[0] = b[0] * 0;
+    b += 2;
+    c += 2;
+  }
+}
index b47d0122aec5690dc36861004ff1bb7ce3aa937a..7af01c6806e3f926763f599aa0f5910ee6990afb 100644 (file)
@@ -3255,12 +3255,15 @@ vect_analyze_data_ref_accesses (vec_info *vinfo,
          DR_GROUP_NEXT_ELEMENT (lastinfo) = stmtinfo_b;
          lastinfo = stmtinfo_b;
 
-         STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a)
-           = !can_group_stmts_p (stmtinfo_a, stmtinfo_b, false);
+         if (! STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a))
+           {
+             STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a)
+               = !can_group_stmts_p (stmtinfo_a, stmtinfo_b, false);
 
-         if (dump_enabled_p () && STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a))
-           dump_printf_loc (MSG_NOTE, vect_location,
-                            "Load suitable for SLP vectorization only.\n");
+             if (dump_enabled_p () && STMT_VINFO_SLP_VECT_ONLY (stmtinfo_a))
+               dump_printf_loc (MSG_NOTE, vect_location,
+                                "Load suitable for SLP vectorization only.\n");
+           }
 
          if (init_b == init_prev
              && !to_fixup.add (DR_GROUP_FIRST_ELEMENT (stmtinfo_a))
@@ -3304,7 +3307,11 @@ vect_analyze_data_ref_accesses (vec_info *vinfo,
            {
              DR_GROUP_NEXT_ELEMENT (g) = DR_GROUP_NEXT_ELEMENT (next);
              if (!newgroup)
-               newgroup = next;
+               {
+                 newgroup = next;
+                 STMT_VINFO_SLP_VECT_ONLY (newgroup)
+                   = STMT_VINFO_SLP_VECT_ONLY (grp);
+               }
              else
                DR_GROUP_NEXT_ELEMENT (ng) = next;
              ng = next;