2014-05-19 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 19 May 2014 14:33:31 +0000 (14:33 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 19 May 2014 14:33:31 +0000 (14:33 +0000)
PR tree-optimization/61221
* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
Do nothing for unreachable blocks.
* tree-ssa-sccvn.c (cond_dom_walker::before_dom_children):
Improve unreachability detection.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210614 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr61221.c [new file with mode: 0644]
gcc/tree-ssa-pre.c
gcc/tree-ssa-sccvn.c

index 90eca0c..1cac5d2 100644 (file)
@@ -1,5 +1,13 @@
 2014-05-19  Richard Biener  <rguenther@suse.de>
 
+       PR tree-optimization/61221
+       * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
+       Do nothing for unreachable blocks.
+       * tree-ssa-sccvn.c (cond_dom_walker::before_dom_children):
+       Improve unreachability detection.
+
+2014-05-19  Richard Biener  <rguenther@suse.de>
+
        PR tree-optimization/61209
        * tree-ssa-sccvn.c (visit_phi): Avoid setting expr to VN_TOP.
 
index 83b4264..bb657c1 100644 (file)
@@ -1,5 +1,10 @@
 2014-05-19  Richard Biener  <rguenther@suse.de>
 
+       PR tree-optimization/61221
+       * gcc.dg/torture/pr61221.c: New testcase.
+
+2014-05-19  Richard Biener  <rguenther@suse.de>
+
        PR tree-optimization/61209
        * gfortran.dg/pr61209.f90: New testcase.
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr61221.c b/gcc/testsuite/gcc.dg/torture/pr61221.c
new file mode 100644 (file)
index 0000000..2524382
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+
+void __assert_fail (void);
+
+int **a, b, c, e, *j;
+short *d, **f;
+
+int *
+foo ()
+{
+  *a = j;
+  if (!(1 & e)) 
+    __assert_fail ();
+  return 0;
+}
+
+void
+bar ()
+{
+  int *g = &b;
+  short **h = &d;
+  if ((f = &d) != h)
+    for (; b;)
+      {
+       int i = 1;
+       if (i)
+         g = foo ();
+       c = 0;
+      }
+  if (!g)
+    __assert_fail ();
+}
index f634f5e..e487d28 100644 (file)
@@ -4010,6 +4010,15 @@ eliminate_dom_walker::before_dom_children (basic_block b)
   /* Mark new bb.  */
   el_avail_stack.safe_push (NULL_TREE);
 
+  /* If this block is not reachable do nothing.  */
+  edge_iterator ei;
+  edge e;
+  FOR_EACH_EDGE (e, ei, b->preds)
+    if (e->flags & EDGE_EXECUTABLE)
+      break;
+  if (!e)
+    return;
+
   for (gsi = gsi_start_phis (b); !gsi_end_p (gsi);)
     {
       gimple stmt, phi = gsi_stmt (gsi);
index bd60372..fc00682 100644 (file)
@@ -4177,11 +4177,13 @@ cond_dom_walker::before_dom_children (basic_block bb)
   if (fail)
     return;
 
-  /* If any of the predecessor edges are still marked as possibly
-     executable consider this block reachable.  */
+  /* If any of the predecessor edges that do not come from blocks dominated
+     by us are still marked as possibly executable consider this block
+     reachable.  */
   bool reachable = bb == ENTRY_BLOCK_PTR_FOR_FN (cfun);
   FOR_EACH_EDGE (e, ei, bb->preds)
-    reachable |= (e->flags & EDGE_EXECUTABLE);
+    if (!dominated_by_p (CDI_DOMINATORS, e->src, bb))
+      reachable |= (e->flags & EDGE_EXECUTABLE);
 
   /* If the block is not reachable all outgoing edges are not
      executable.  */