fix PR68428: ignore bb dominated by the scop->exit
authorAditya Kumar <aditya.k7@samsung.com>
Thu, 19 Nov 2015 23:06:18 +0000 (23:06 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Thu, 19 Nov 2015 23:06:18 +0000 (23:06 +0000)
Co-Authored-By: Sebastian Pop <s.pop@samsung.com>
From-SVN: r230632

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

index 4b8bd47919c910f6de6bdd8a32f1c7b00efde065..949e12e580efe52eeab9282c9e994e7a39993b3c 100644 (file)
@@ -1,3 +1,10 @@
+2015-11-19  Aditya Kumar  <aditya.k7@samsung.com>
+           Sebastian Pop  <s.pop@samsung.com>
+
+       PR tree-optimization/68428
+       * graphite-scop-detection.c (harmful_stmt_in_region): Do not iterate
+       over basic blocks outside the scop.
+
 2015-11-19  Aditya Kumar  <aditya.k7@samsung.com>
            Sebastian Pop  <s.pop@samsung.com>
 
index e42b9bf9c41c852d366a0b5657ba9d1339965a5c..84fe945e74a75d711598c85ed8af13b39cca8690 100644 (file)
@@ -1062,12 +1062,16 @@ scop_detection::harmful_stmt_in_region (sese_l scop) const
   basic_block bb;
   FOR_EACH_VEC_ELT (dom, i, bb)
     {
-      DEBUG_PRINT (dp << "\nVisiting bb_" << bb->index);
+      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)
        {
index 1290aa0f47e3365589a5e0c78f9d2186ad593c3d..f107483de21f298ba6778d7a2ee42a8ef6e167d6 100644 (file)
@@ -1,3 +1,9 @@
+2015-11-19  Aditya Kumar  <aditya.k7@samsung.com>
+           Sebastian Pop  <s.pop@samsung.com>
+
+       PR tree-optimization/68428
+       * gcc.dg/graphite/pr68428.c: New.
+
 2015-11-19  Aditya Kumar  <aditya.k7@samsung.com>
            Sebastian Pop  <s.pop@samsung.com>
 
diff --git a/gcc/testsuite/gcc.dg/graphite/pr68428.c b/gcc/testsuite/gcc.dg/graphite/pr68428.c
new file mode 100644 (file)
index 0000000..2dc63b7
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+int au[4] = { 0 };
+
+int
+main(void)
+{
+  int dc;
+  int m7;
+  int lv;
+  int f2;
+  int uq[3] = { 1 };
+  for (dc = 0; dc < 2; ++dc) {
+    for (lv = 0; lv < 2; ++lv)
+      for (m7 = 0; m7 < 3; ++m7) {
+        if (uq[dc] == 0)
+          continue;
+        for (f2 = 0; f2 < 3; ++f2)
+          au[dc+2] = uq[f2];
+      }
+  }
+  return 0;
+}