re PR tree-optimization/86865 (Wrong code w/ -O2 -floop-parallelize-all -fstack-reuse...
authorRichard Biener <rguenther@suse.de>
Fri, 25 Jan 2019 08:13:34 +0000 (08:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 25 Jan 2019 08:13:34 +0000 (08:13 +0000)
2019-01-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/86865
* graphite-scop-detection.c (scop_detection::can_represent_loop):
Reject non-do-while loops.

* gcc.dg/graphite/pr86865.c: New testcase.
* gcc.dg/graphite/pr69728.c: XFAIL.
* gcc.dg/graphite/scop-21.c: Likewise.

From-SVN: r268257

gcc/ChangeLog
gcc/graphite-scop-detection.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr69728.c
gcc/testsuite/gcc.dg/graphite/pr86865.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/graphite/scop-21.c

index 7156b64dc1dc91e8e5f250a43494798bbf1d40b0..bdcd4739fa402be6e3224f958eba952a93843477 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86865
+       * graphite-scop-detection.c (scop_detection::can_represent_loop):
+       Reject non-do-while loops.
+
 2019-01-24  Peter Bergner  <bergner@linux.ibm.com>
 
        * config/rs6000/altivec.md (build_vector_mask_for_load): Use MEM_P.
index 57d3b4806c8a78a3d20e634cc51dcf96a401ef3d..7e8d42cab0d17ba65f50f190e91ca1290bab231f 100644 (file)
@@ -555,8 +555,15 @@ scop_detection::can_represent_loop (loop_p loop, sese_l scop)
   tree niter;
   struct tree_niter_desc niter_desc;
 
-  return single_exit (loop)
-    && !(loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP)
+  /* We can only handle do {} while () style loops correctly.  */
+  edge exit = single_exit (loop);
+  if (!exit
+      || !single_pred_p (loop->latch)
+      || exit->src != single_pred (loop->latch)
+      || !empty_block_p (loop->latch))
+    return false;
+
+  return !(loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP)
     && number_of_iterations_exit (loop, single_exit (loop), &niter_desc, false)
     && niter_desc.control.no_overflow
     && (niter = number_of_latch_executions (loop))
index fa88d9d35cba0d0f2d2f92bf6983e684108ed605..9803c91e40bc261f23ec2e9f5e1d7240568fe047 100644 (file)
@@ -1,3 +1,10 @@
+2019-01-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86865
+       * gcc.dg/graphite/pr86865.c: New testcase.
+       * gcc.dg/graphite/pr69728.c: XFAIL.
+       * gcc.dg/graphite/scop-21.c: Likewise.
+
 2019-01-24  Martin Sebor  <msebor@redhat.com>
 
        PR c/86125
index e8cd7bec0a1045e908e6605d8f2046907213fdcc..69e28318aafe957e1c8f1df4c57e3ee07045d92f 100644 (file)
@@ -24,4 +24,6 @@ fn1 ()
    run into scheduling issues before here, not being able to handle
    empty domains.  */
 
-/* { dg-final { scan-tree-dump "loop nest optimized" "graphite" } }  */
+/* XFAILed by fix for PR86865.  */
+
+/* { dg-final { scan-tree-dump "loop nest optimized" "graphite" { xfail *-*-* } } }  */
diff --git a/gcc/testsuite/gcc.dg/graphite/pr86865.c b/gcc/testsuite/gcc.dg/graphite/pr86865.c
new file mode 100644 (file)
index 0000000..a6b4208
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fgraphite-identity -fstack-reuse=none -fwrapv -fno-tree-ch -fno-tree-dce -fno-tree-dominator-opts -fno-tree-loop-ivcanon" } */
+
+int xy, tb;
+
+void
+bt (void)
+{
+  for (xy = 0; xy >= 0; --xy)
+    {
+      int yt[8] = { 0 };
+      int pz[2] = { 0 };
+      int sa[32] = { 0 };
+      int us;
+
+      for (us = 0; us < 8; ++us)
+       yt[us] = 0;
+
+      (void) yt;
+      (void) pz;
+      (void) sa;
+    }
+
+  tb = 1;
+}
+
+int
+main (void)
+{
+  bt ();
+  if (xy != -1)
+    __builtin_abort ();
+
+  return 0;
+}
index bd3f811d9d11d58a341993b5eab15eb1f103afb6..304e0792b2bfd2deedb5f697e1b205a11aa11eb9 100644 (file)
@@ -30,4 +30,5 @@ int test ()
 
   return a[20];
 }
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */
+/* XFAILed by the fix for PR86865.  */
+/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite" { xfail *-*-* } } } */