re PR tree-optimization/87022 (miscompilation with -ftree-loop-distribution)
authorBin Cheng <bin.cheng@linux.alibaba.com>
Mon, 15 Oct 2018 11:35:56 +0000 (11:35 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Mon, 15 Oct 2018 11:35:56 +0000 (11:35 +0000)
PR tree-optimization/87022
* tree-loop-distribution.c (pg_add_dependence_edges): Check all
bits in dist vector rather than the first one.

gcc/testsuite
PR tree-optimization/87022
* gcc.dg/tree-ssa/pr87022.c: New test.

From-SVN: r265161

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr87022.c [new file with mode: 0644]
gcc/tree-loop-distribution.c

index 742f5cf837057de8de53e368d1e31cf26ecd63b8..a11504a10c206cfed2795e28c486fbf5307964dd 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-15  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       PR tree-optimization/87022
+       * tree-loop-distribution.c (pg_add_dependence_edges): Check all
+       bits in dist vector rather than the first one.
+
 2018-10-15  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/87610
index e189162c654c5af6847b23372c1908c255f9ca2b..df20c3c93dd3f300ae732a71fc2e3be249a983e3 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-15  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       PR tree-optimization/87022
+       * gcc.dg/tree-ssa/pr87022.c: New test.
+
 2018-10-15  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/87610
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr87022.c b/gcc/testsuite/gcc.dg/tree-ssa/pr87022.c
new file mode 100644 (file)
index 0000000..b882c35
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+void abort();
+char a[7];
+char b[10][7];
+char r[10][7] = { {0,0,0,0,0,0,0},
+                 {0,0,0,0,0,0,0},
+                 {0,0,0,0,0,0,0},
+                 {0,0,0,0,0,0,0},
+                 {0,0,0,0,0,0,0},
+                 {0,0,0,0,0,0,0},
+                 {0,0,0,0,0,0,0},
+                 {0,0,1,1,1,1,1},
+                 {0,0,1,1,1,1,1},
+                 {0,0,1,1,1,1,1}};
+short c;
+int d, e, f, g;
+int main() {
+  for (; d <= 4; d++) {
+    e = 0;
+    for (; e <= 6; e++) {
+      if (a[c])
+        b[e + 3][d + 2] = 1;
+      a[0] = 5;
+      b[e][d + 2] = 0;
+    }
+  }
+  for (; f < 10; f++) {
+    g = 0;
+    for (; g < 7; g++)
+      if (b[f][g] != r[f][g])
+        abort ();
+  }
+  return 0;
+}
index d8db03b545b08929a28cd81fd3308c77bc5e151c..1e8a9f0991be608d6d43c2368b61d66f526d80ec 100644 (file)
@@ -1921,7 +1921,8 @@ pg_add_dependence_edges (struct graph *rdg, int dir,
              if (DDR_NUM_DIST_VECTS (ddr) != 1)
                this_dir = 2;
              /* If the overlap is exact preserve stmt order.  */
-             else if (lambda_vector_zerop (DDR_DIST_VECT (ddr, 0), 1))
+             else if (lambda_vector_zerop (DDR_DIST_VECT (ddr, 0),
+                                           DDR_NB_LOOPS (ddr)))
                ;
              /* Else as the distance vector is lexicographic positive swap
                 the dependence direction.  */