]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/111915 - mixing grouped and non-grouped accesses
authorRichard Biener <rguenther@suse.de>
Mon, 23 Oct 2023 11:42:53 +0000 (13:42 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 23 Oct 2023 13:30:02 +0000 (15:30 +0200)
The change to allow SLP of non-grouped accesses failed to check
for the case of mixing with grouped accesses.

PR tree-optimization/111915
* tree-vect-slp.cc (vect_build_slp_tree_1): Check all
accesses are either grouped or not.

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

gcc/testsuite/gcc.dg/vect/pr111915.c [new file with mode: 0644]
gcc/tree-vect-slp.cc

diff --git a/gcc/testsuite/gcc.dg/vect/pr111915.c b/gcc/testsuite/gcc.dg/vect/pr111915.c
new file mode 100644 (file)
index 0000000..8614bac
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-vrp -fno-tree-dominator-opts -fno-tree-ccp" } */
+
+void
+foo (int * __restrict a, int * __restrict b, int * __restrict w)
+{
+  for (int i = 0; i < 16; ++i)
+    {
+      *a += w[2*i+0];
+      *b += w[2*i&1];
+    }
+}
index 24bf6582f8dfab44711484a002c139f779099102..5eb310eceaf828dd583b3c21b36f18ccf5f375ec 100644 (file)
@@ -1297,6 +1297,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
                        || rhs_code == INDIRECT_REF
                        || rhs_code == COMPONENT_REF
                        || rhs_code == MEM_REF)))
+             || (ldst_p
+                 && (STMT_VINFO_GROUPED_ACCESS (stmt_info)
+                     != STMT_VINFO_GROUPED_ACCESS (first_stmt_info)))
              || (ldst_p
                  && (STMT_VINFO_GATHER_SCATTER_P (stmt_info)
                      != STMT_VINFO_GATHER_SCATTER_P (first_stmt_info)))