OSDN Git Service

gcc/
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Apr 2005 15:33:17 +0000 (15:33 +0000)
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Apr 2005 15:33:17 +0000 (15:33 +0000)
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.

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

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

index 3d0636c..1f484e0 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 6faba54..91ec4c8 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 fa66ab9..e8f52bb 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
     {