re PR tree-optimization/61680 (vectorization gives wrong answer for sandybridge target)
authorRichard Biener <rguenther@suse.de>
Tue, 8 Jul 2014 08:59:17 +0000 (08:59 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 8 Jul 2014 08:59:17 +0000 (08:59 +0000)
2014-07-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/61680
* tree-vect-data-refs.c (vect_analyze_data_ref_dependence):
Handle properly all read-write dependences with group accesses.

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

From-SVN: r212348

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

index 84ed782..726c86f 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/61680
+       * tree-vect-data-refs.c (vect_analyze_data_ref_dependence):
+       Handle properly all read-write dependences with group accesses.
+
 2014-07-08  Yuri Rumyantsev  <ysrumyan@gmail.com>
 
        PR tree-optimization/61576
index 1350da4..523e6c4 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/61680
+       * gcc.dg/vect/pr61680.c: New testcase.
+
 2014-07-08  Yuri Rumyantsev  <ysrumyan@gmail.com>
 
        PR tree-optimization/61576
diff --git a/gcc/testsuite/gcc.dg/vect/pr61680.c b/gcc/testsuite/gcc.dg/vect/pr61680.c
new file mode 100644 (file)
index 0000000..605a651
--- /dev/null
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+double v[4096][4];
+
+__attribute__((noinline, noclone)) void
+bar (double p[][4])
+{
+  int i;
+  double d = 172.0;
+  for (i = 0; i < 4096; i++)
+    {
+      if (p[i][0] != 6.0 || p[i][1] != 6.0 || p[i][2] != 10.0)
+       __builtin_abort ();
+      if (__builtin_fabs (p[i][3] - d) > 0.25)
+       __builtin_abort ();
+    }
+}
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+  int i;
+  double w[4096][4], t;
+  for (i = 0; i < 4096; i++)
+    {
+      w[i][0] = v[i][0] + 2.0;
+      w[i][1] = v[i][1] + 1.0;
+      w[i][2] = v[i][2] + 4.0;
+      w[i][3] = (w[i][0] * w[i][0] + w[i][1] * w[i][1] + w[i][2] * w[i][2]);
+    }
+  bar (w);
+}
+
+int
+main ()
+{
+  int i;
+
+  check_vect ();
+
+  for (i = 0; i < 4096; i++)
+    {
+      v[i][0] = 4.0;
+      v[i][1] = 5.0;
+      v[i][2] = 6.0;
+    }
+  foo ();
+  return 0;
+}
index 93a14cf..ea2316c 100644 (file)
@@ -375,11 +375,14 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
                .. = a[i+1];
             where we will end up loading { a[i], a[i+1] } once, make
             sure that inserting group loads before the first load and
-            stores after the last store will do the right thing.  */
-         if ((STMT_VINFO_GROUPED_ACCESS (stmtinfo_a)
-              && GROUP_SAME_DR_STMT (stmtinfo_a))
-             || (STMT_VINFO_GROUPED_ACCESS (stmtinfo_b)
-                 && GROUP_SAME_DR_STMT (stmtinfo_b)))
+            stores after the last store will do the right thing.
+            Similar for groups like
+               a[i] = ...;
+               ... = a[i];
+               a[i+1] = ...;
+            where loads from the group interleave with the store.  */
+         if (STMT_VINFO_GROUPED_ACCESS (stmtinfo_a)
+             || STMT_VINFO_GROUPED_ACCESS (stmtinfo_b))
            {
              gimple earlier_stmt;
              earlier_stmt = get_earlier_stmt (DR_STMT (dra), DR_STMT (drb));