Fix DR_GROUP_GAP for strided accesses (PR 92677)
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 29 Nov 2019 14:48:30 +0000 (14:48 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Fri, 29 Nov 2019 14:48:30 +0000 (14:48 +0000)
When dissolving an SLP-only group of accesses, we should only set
the gap to group_size - 1 for normal non-strided groups.

2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
PR tree-optimization/92677
* tree-vect-loop.c (vect_dissolve_slp_only_groups): Set the gap
to zero when dissolving a group of strided accesses.

gcc/testsuite/
PR tree-optimization/92677
* gcc.dg/vect/pr92677.c: New test.

From-SVN: r278852

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr92677.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index 002d9aa1217c1d67fc366ed29e7f17b2eaf95485..ea1a587f80b178967aca4e9e391a76ee7c265dba 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/92677
+       * tree-vect-loop.c (vect_dissolve_slp_only_groups): Set the gap
+       to zero when dissolving a group of strided accesses.
+
 2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/92596
index 57544a5c17a3c4265b59ac263c5be977748452f9..375202bc493d54928bfb157e7eeb267e8ad03501 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/92677
+       * gcc.dg/vect/pr92677.c: New test.
+
 2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/92596
diff --git a/gcc/testsuite/gcc.dg/vect/pr92677.c b/gcc/testsuite/gcc.dg/vect/pr92677.c
new file mode 100644 (file)
index 0000000..3f85b29
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+int a, c;
+int *b;
+long d;
+double *e;
+
+void fn1() {
+  long f;
+  double g, h;
+  while (c) {
+    if (d) {
+      g = *e;
+      *(b + 4) = g;
+    }
+    if (f) {
+      h = *(e + 2);
+      *(b + 6) = h;
+    }
+    e += a;
+    b += 8;
+    c--;
+    d += 2;
+  }
+}
index ab48a05dbed35ec59904cd409d9a84b87f1b62fc..77c5a9816e2fa6b3592575daa93984e3f93236e3 100644 (file)
@@ -1829,7 +1829,10 @@ vect_dissolve_slp_only_groups (loop_vec_info loop_vinfo)
                  DR_GROUP_FIRST_ELEMENT (vinfo) = vinfo;
                  DR_GROUP_NEXT_ELEMENT (vinfo) = NULL;
                  DR_GROUP_SIZE (vinfo) = 1;
-                 DR_GROUP_GAP (vinfo) = group_size - 1;
+                 if (STMT_VINFO_STRIDED_P (first_element))
+                   DR_GROUP_GAP (vinfo) = 0;
+                 else
+                   DR_GROUP_GAP (vinfo) = group_size - 1;
                  vinfo = next;
                }
            }