re PR tree-optimization/69823 (internal compiler error: in create_pw_aff_from_tree...
authorRichard Biener <rguenther@suse.de>
Thu, 9 Feb 2017 07:47:07 +0000 (07:47 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 9 Feb 2017 07:47:07 +0000 (07:47 +0000)
2017-02-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/69823
* graphite-scop-detection.c (scop_detection::harmful_loop_in_region):
Properly enumerate all BBs in the region.  Use auto_vec/auto_bitmap.

* gcc.dg/graphite/pr69823.c: New testcase.

From-SVN: r245295

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

index 8865d74..fcbb10c 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69823
+       * graphite-scop-detection.c (scop_detection::harmful_loop_in_region):
+       Properly enumerate all BBs in the region.  Use auto_vec/auto_bitmap.
+
 2017-02-09  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * config/arc/arc-c.def: Add __NPS400__ definition.
index ee1f705..c372141 100644 (file)
@@ -1062,35 +1062,18 @@ scop_detection::harmful_loop_in_region (sese_l scop) const
               print_sese (dump_file, scop));
   gcc_assert (dominated_by_p (CDI_DOMINATORS, exit_bb, entry_bb));
 
-  int depth = bb_dom_dfs_in (CDI_DOMINATORS, exit_bb)
-    - bb_dom_dfs_in (CDI_DOMINATORS, entry_bb);
+  auto_vec<basic_block> worklist;
+  auto_bitmap loops;
 
-  gcc_assert (depth > 0);
-
-  vec<basic_block> dom
-      = get_dominated_to_depth (CDI_DOMINATORS, entry_bb, depth);
-  int i;
-  basic_block bb;
-  bitmap loops = BITMAP_ALLOC (NULL);
-  FOR_EACH_VEC_ELT (dom, i, bb)
+  worklist.safe_push (entry_bb);
+  while (! worklist.is_empty ())
     {
+      basic_block bb = worklist.pop ();
       DEBUG_PRINT (dp << "Visiting bb_" << bb->index << "\n");
 
-      /* We don't want to analyze any bb outside sese.  */
-      if (!dominated_by_p (CDI_POST_DOMINATORS, bb, exit_bb))
-       continue;
-
-      /* Basic blocks dominated by the scop->exit are not in the scop.  */
-      if (bb != exit_bb && dominated_by_p (CDI_DOMINATORS, bb, exit_bb))
-       continue;
-
       /* The basic block should not be part of an irreducible loop.  */
       if (bb->flags & BB_IRREDUCIBLE_LOOP)
-       {
-         dom.release ();
-         BITMAP_FREE (loops);
-         return true;
-       }
+       return true;
 
       /* Check for unstructured control flow: CFG not generated by structured
         if-then-else.  */
@@ -1114,13 +1097,14 @@ scop_detection::harmful_loop_in_region (sese_l scop) const
             any loop fully contained in the scop: other bbs are checked below
             in loop_is_valid_in_scop.  */
          if (harmful_stmt_in_bb (scop, bb))
-           {
-             dom.release ();
-             BITMAP_FREE (loops);
-             return true;
-           }
+           return true;
        }
 
+      if (bb != exit_bb)
+       for (basic_block dom = first_dom_son (CDI_DOMINATORS, bb);
+            dom;
+            dom = next_dom_son (CDI_DOMINATORS, dom))
+         worklist.safe_push (dom);
     }
 
   /* Go through all loops and check that they are still valid in the combined
@@ -1133,15 +1117,9 @@ scop_detection::harmful_loop_in_region (sese_l scop) const
       gcc_assert (loop->num == (int) j);
 
       if (!loop_is_valid_in_scop (loop, scop))
-       {
-         dom.release ();
-         BITMAP_FREE (loops);
-         return true;
-       }
+       return true;
     }
 
-  dom.release ();
-  BITMAP_FREE (loops);
   return false;
 }
 
index ba30165..aeba293 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69823
+       * gcc.dg/graphite/pr69823.c: New testcase.
+
 2017-02-08  Pat Haugen  <pthaugen@us.ibm.com>
 
        PR target/78604
diff --git a/gcc/testsuite/gcc.dg/graphite/pr69823.c b/gcc/testsuite/gcc.dg/graphite/pr69823.c
new file mode 100644 (file)
index 0000000..6f2d35e
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+void
+foo (int c, int *p, int *a1, int *a2, int *a3)
+{
+  int i;
+
+  if (c)
+    {
+      for (i = 0; i < 8; i++)
+       a1[i] = 1;
+
+      if (*p)
+       *a2 = 0;
+    }
+
+  for (i = 0; i < 8; i++)
+    a3[i] = 0;
+}