summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-propagate.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-23 07:23:23 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-23 07:23:23 +0000
commit930490667fefb728837333448730d9a889249bd0 (patch)
tree0b53234d12f8b5bc5dfcbdc0f99a0ae83f98d561 /gcc/tree-ssa-propagate.c
parent43f467b0bb347fcc59d71799f86de53e6933e78e (diff)
downloadgcc-930490667fefb728837333448730d9a889249bd0.tar.gz
2015-07-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/66945 * tree-ssa-propagate.c (substitute_and_fold_dom_walker ::before_dom_children): Force the propagators idea of non-executable edges to materialize, not what the folder chooses. * gcc.dg/torture/pr66945.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226088 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-propagate.c')
-rw-r--r--gcc/tree-ssa-propagate.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 3f3a694702e..b7684e07905 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1236,13 +1236,33 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
/* If we made a replacement, fold the statement. */
if (did_replace)
- fold_stmt (&i, follow_single_use_edges);
+ {
+ fold_stmt (&i, follow_single_use_edges);
+ stmt = gsi_stmt (i);
+ }
+
+ /* If this is a control statement the propagator left edges
+ unexecuted on force the condition in a way consistent with
+ that. See PR66945 for cases where the propagator can end
+ up with a different idea of a taken edge than folding
+ (once undefined behavior is involved). */
+ if (gimple_code (stmt) == GIMPLE_COND)
+ {
+ if ((EDGE_SUCC (bb, 0)->flags & EDGE_EXECUTABLE)
+ ^ (EDGE_SUCC (bb, 1)->flags & EDGE_EXECUTABLE))
+ {
+ if (((EDGE_SUCC (bb, 0)->flags & EDGE_TRUE_VALUE) != 0)
+ == ((EDGE_SUCC (bb, 0)->flags & EDGE_EXECUTABLE) != 0))
+ gimple_cond_make_true (as_a <gcond *> (stmt));
+ else
+ gimple_cond_make_false (as_a <gcond *> (stmt));
+ did_replace = true;
+ }
+ }
/* Now cleanup. */
if (did_replace)
{
- stmt = gsi_stmt (i);
-
/* If we cleaned up EH information from the statement,
remove EH edges. */
if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt))