Commit 60b4ccde by Kazu Hirata Committed by Kazu Hirata

re PR tree-optimization/20913 (copy-prop does not fold conditionals)

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
parent 9fb6cbd9
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
PR tree-optimization/20913 PR tree-optimization/20913
* tree-ssa-copy.c (copy_prop_visit_cond_stmt): Fold COND_EXPR. * 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> 2005-04-13 Julian Brown <julian@codesourcery.com>
* config/elfos.h (MAKE_DECL_ONE_ONLY): Redefined to stop DECL_WEAK from * config/elfos.h (MAKE_DECL_ONE_ONLY): Redefined to stop DECL_WEAK from
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
PR tree-optimization/20913 PR tree-optimization/20913
* gcc.dg/tree-ssa/pr20913.c: New. * 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> 2005-04-13 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/13744 PR c++/13744
......
/* 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"} } */
...@@ -1500,6 +1500,7 @@ maybe_add_assert_expr (basic_block bb) ...@@ -1500,6 +1500,7 @@ maybe_add_assert_expr (basic_block bb)
edge e; edge e;
edge_iterator ei; edge_iterator ei;
tree op, cond; tree op, cond;
basic_block son;
cond = COND_EXPR_COND (last); cond = COND_EXPR_COND (last);
...@@ -1554,6 +1555,17 @@ maybe_add_assert_expr (basic_block bb) ...@@ -1554,6 +1555,17 @@ maybe_add_assert_expr (basic_block bb)
/* Finally, mark all the COND_EXPR operands as found. */ /* Finally, mark all the COND_EXPR operands as found. */
SET_BIT (found, SSA_NAME_VERSION (op)); 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 else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment