re PR tree-optimization/20913 (copy-prop does not fold conditionals)
authorKazu Hirata <kazu@cs.umass.edu>
Wed, 13 Apr 2005 15:33:17 +0000 (15:33 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Wed, 13 Apr 2005 15:33:17 +0000 (15:33 +0000)
gcc/
PR tree-optimization/20913
* tree-ssa-copy.c (copy_prop_visit_cond_stmt): Fold COND_EXPR.

testsuite/
PR tree-optimization/20913
* gcc.dg/tree-ssa/pr20913.c: New.

From-SVN: r98091

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr20702.c [new file with mode: 0644]
gcc/tree-vrp.c

index 3d0636cc6f8fdfa8f8a28fb26167b8414b6bef00..1f484e004f7bbdf98a42d21c888c2eb56c18d1b7 100644 (file)
@@ -3,6 +3,10 @@
        PR tree-optimization/20913
        * tree-ssa-copy.c (copy_prop_visit_cond_stmt): Fold COND_EXPR.
 
+       PR tree-optimization/20702
+       * tree-vrp.c (maybe_add_assert_expr): Recurse into
+       dominator children that haven't been walked into.
+
 2005-04-13  Julian Brown  <julian@codesourcery.com>
 
        * config/elfos.h (MAKE_DECL_ONE_ONLY): Redefined to stop DECL_WEAK from
index 6faba54bdb00948aa56d4c3b09263e208cf7c035..91ec4c82b34cc6d3ce15cb2bfc6313f48de913ab 100644 (file)
@@ -3,6 +3,9 @@
        PR tree-optimization/20913
        * gcc.dg/tree-ssa/pr20913.c: New.
 
+       PR tree-optimization/20702
+       * gcc.dg/tree-ssa/pr20702.c: New.
+
 2005-04-13  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/13744
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20702.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20702.c
new file mode 100644 (file)
index 0000000..c6f1ae6
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR tree-optimization/20702
+   VRP did not insert ASSERT_EXPRs into dominator dominator children
+   of a basic block ending with COND_EXPR unless the children are also
+   immediate successors of the basic block.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp-details" } */
+
+extern void bar (int);
+
+int
+foo (int *p, int b)
+{
+  int a;
+
+  if (b)
+    bar (123);
+  else
+    bar (321);
+
+  a = *p;
+  if (p == 0)
+    return 0;
+
+  return a;
+}
+
+/* { dg-final { scan-tree-dump-times "Folding predicate" 1 "vrp"} } */
index fa66ab94a62850f7399b515400c6d086f83c17af..e8f52bb72f40491d4c61f47a1de4db44924d5f04 100644 (file)
@@ -1500,6 +1500,7 @@ maybe_add_assert_expr (basic_block bb)
       edge e;
       edge_iterator ei;
       tree op, cond;
+      basic_block son;
       
       cond = COND_EXPR_COND (last);
 
@@ -1554,6 +1555,17 @@ maybe_add_assert_expr (basic_block bb)
 
       /* Finally, mark all the COND_EXPR operands as found.  */
       SET_BIT (found, SSA_NAME_VERSION (op));
+
+      /* Recurse into the dominator children of BB that are not BB's
+        immediate successors.  Note that we have already visited BB's
+        other dominator children above.  */
+      for (son = first_dom_son (CDI_DOMINATORS, bb);
+          son;
+          son = next_dom_son (CDI_DOMINATORS, son))
+       {
+         if (find_edge (bb, son) == NULL)
+           added |= maybe_add_assert_expr (son);
+       }
     }
   else
     {