diff options
author | Richard Biener <rguenther@suse.de> | 2015-07-23 07:23:23 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2015-07-23 07:23:23 +0000 |
commit | 28537a45de776c6d4eb4a21447374e27acc4573d (patch) | |
tree | 0b53234d12f8b5bc5dfcbdc0f99a0ae83f98d561 | |
parent | bde7d04b62f9fbc95131c4246ff2da7d063bda31 (diff) | |
download | gcc-28537a45de776c6d4eb4a21447374e27acc4573d.zip gcc-28537a45de776c6d4eb4a21447374e27acc4573d.tar.gz gcc-28537a45de776c6d4eb4a21447374e27acc4573d.tar.bz2 |
re PR middle-end/66945 (ICE in generic_simplify (generic-match.c:24790))
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.
From-SVN: r226088
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr66945.c | 12 | ||||
-rw-r--r-- | gcc/tree-ssa-propagate.c | 26 |
4 files changed, 48 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7cd07f9..e89f685 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 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. + +2015-07-23 Richard Biener <rguenther@suse.de> + * gimple.h (gimple_cond_make_false): Use 0 != 0. (gimple_cond_make_true): Use 1 != 0. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f457b27..20fad26 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-23 Richard Biener <rguenther@suse.de> + + PR tree-optimization/66945 + * gcc.dg/torture/pr66945.c: New testcase. + 2015-07-22 Uros Bizjak <ubizjak@gmail.com> PR target/66954 diff --git a/gcc/testsuite/gcc.dg/torture/pr66945.c b/gcc/testsuite/gcc.dg/torture/pr66945.c new file mode 100644 index 0000000..53ac230 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr66945.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +unsigned b; +void f() +{ + for(;;) + if(!b?:(b=0)) + ; + else if(b%0<b?:b) /* { dg-warning "division by zero" } */ + for(;;) + ; +} diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 3f3a694..b7684e0 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)) |