aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-05-02 07:40:22 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-05-02 07:40:22 +0000
commit9e4da9b5d5d3d8e14ab1748fafb08c6b9bfcf629 (patch)
treecc2d2a65d221c55d054add0a6d8e0909b1c800d6 /gcc
parentc2e1580cbe2023f9a7ff832d52587825c85c2f6d (diff)
downloadgcc-9e4da9b5d5d3d8e14ab1748fafb08c6b9bfcf629.zip
gcc-9e4da9b5d5d3d8e14ab1748fafb08c6b9bfcf629.tar.gz
gcc-9e4da9b5d5d3d8e14ab1748fafb08c6b9bfcf629.tar.bz2
Tighten early exit in vect_analyze_data_ref_dependence (PR85586)
The problem in this PR was that we didn't consider aliases between writes in the same strided group. After tightening the early exit we get the expected abs(step) >= 2 versioning check. 2018-05-02 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR tree-optimization/85586 * tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Only exit early for statements in the same group if the accesses are not strided. gcc/testsuite/ PR tree-optimization/85586 * gcc.dg/vect/pr85586.c: New test. From-SVN: r259822
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr85586.c43
-rw-r--r--gcc/tree-vect-data-refs.c6
4 files changed, 59 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 65f76ab..53fa68d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-05-02 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR tree-optimization/85586
+ * tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Only
+ exit early for statements in the same group if the accesses are
+ not strided.
+
2018-05-02 Tom de Vries <tom@codesourcery.com>
PR lto/85451
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 465b079..9c93c81 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-02 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR tree-optimization/85586
+ * gcc.dg/vect/pr85586.c: New test.
+
2018-05-01 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/85143
diff --git a/gcc/testsuite/gcc.dg/vect/pr85586.c b/gcc/testsuite/gcc.dg/vect/pr85586.c
new file mode 100644
index 0000000..d6cc92d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr85586.c
@@ -0,0 +1,43 @@
+#define N 100
+
+void __attribute__ ((noipa))
+foo (int *out, int *in, int step)
+{
+ for (int i = 0; i < N; ++i)
+ {
+ out[0] = in[i];
+ out[1] = 2;
+ out += step;
+ }
+}
+
+int in[N];
+int out[N * 2];
+
+int
+main (void)
+{
+ for (int i = 0; i < N; ++i)
+ {
+ in[i] = i * (i + 1);
+ asm volatile ("" ::: "memory");
+ }
+
+ foo (out, in, 1);
+ for (int i = 0; i < N; ++i)
+ if (out[i] != in[i])
+ __builtin_abort ();
+ if (out[N] != 2)
+ __builtin_abort ();
+
+ foo (out + N - 1, in, -1);
+ if (out[0] != in[N - 1])
+ __builtin_abort ();
+ for (int i = 1; i <= N; ++i)
+ if (out[i] != 2)
+ __builtin_abort ();
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target vect_int } } } */
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index df362b0..9608b76 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -305,9 +305,11 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
return false;
/* We do not have to consider dependences between accesses that belong
- to the same group. */
+ to the same group, unless the stride could be smaller than the
+ group size. */
if (GROUP_FIRST_ELEMENT (stmtinfo_a)
- && GROUP_FIRST_ELEMENT (stmtinfo_a) == GROUP_FIRST_ELEMENT (stmtinfo_b))
+ && GROUP_FIRST_ELEMENT (stmtinfo_a) == GROUP_FIRST_ELEMENT (stmtinfo_b)
+ && !STMT_VINFO_STRIDED_P (stmtinfo_a))
return false;
/* Even if we have an anti-dependence then, as the vectorized loop covers at