The following fixes an issue I introduced late with some re-org
introducing BB_EXCUTABLE ...

O1-bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2018-08-30  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/87147
        * tree-ssa-sccvn.c (do_rpo_vn): Properly mark blocks with
        incoming backedges as executable.

        * gcc.dg/torture/pr87147.c: New testcase.

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c        (revision 263972)
+++ gcc/tree-ssa-sccvn.c        (working copy)
@@ -6298,6 +6298,7 @@ do_rpo_vn (function *fn, edge entry, bit
     {
       basic_block bb = BASIC_BLOCK_FOR_FN (fn, rpo[i]);
       rpo_state[i].visited = 0;
+      bb->flags &= ~BB_EXECUTABLE;
       bool has_backedges = false;
       edge e;
       edge_iterator ei;
@@ -6306,12 +6307,14 @@ do_rpo_vn (function *fn, edge entry, bit
          if (e->flags & EDGE_DFS_BACK)
            has_backedges = true;
          if (! iterate && (e->flags & EDGE_DFS_BACK))
-           e->flags |= EDGE_EXECUTABLE;
+           {
+             e->flags |= EDGE_EXECUTABLE;
+             bb->flags |= BB_EXECUTABLE;
+           }
          else
            e->flags &= ~EDGE_EXECUTABLE;
        }
       rpo_state[i].iterate = iterate && has_backedges;
-      bb->flags &= ~BB_EXECUTABLE;
     }
   entry->flags |= EDGE_EXECUTABLE;
   entry->dest->flags |= BB_EXECUTABLE;
Index: gcc/testsuite/gcc.dg/torture/pr87147.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr87147.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr87147.c      (working copy)
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+short a;
+long b;
+int c, d, g;
+char e, h;
+long f[] = {0};
+int main()
+{
+  int i = 1;
+  for (; a <= 3; a++) {
+      c = 0;
+      for (; c <= 2; c++) {
+         b = 0;
+         for (; b <= 3; b++) {
+             h = i && f[d];
+             e = g && i;
+             i = 0;
+         }
+      }
+  }
+}

Reply via email to