From 1d44def2c2faae5f7e5a58fb57e0c9991a339bd5 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 19 May 2014 14:33:31 +0000 Subject: [PATCH] re PR tree-optimization/61221 (ICE on valid code at -O1 and above on x86_64-linux-gnu) 2014-05-19 Richard Biener PR tree-optimization/61221 * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Do nothing for unreachable blocks. * tree-ssa-sccvn.c (cond_dom_walker::before_dom_children): Improve unreachability detection. * gcc.dg/torture/pr61221.c: New testcase. From-SVN: r210614 --- gcc/ChangeLog | 8 +++++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/torture/pr61221.c | 32 ++++++++++++++++++++++++++ gcc/tree-ssa-pre.c | 9 ++++++++ gcc/tree-ssa-sccvn.c | 8 ++++--- 5 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr61221.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 90eca0c687b..1cac5d27fb5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-05-19 Richard Biener + + PR tree-optimization/61221 + * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): + Do nothing for unreachable blocks. + * tree-ssa-sccvn.c (cond_dom_walker::before_dom_children): + Improve unreachability detection. + 2014-05-19 Richard Biener PR tree-optimization/61209 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 83b42642cdc..bb657c1b5a9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-05-19 Richard Biener + + PR tree-optimization/61221 + * gcc.dg/torture/pr61221.c: New testcase. + 2014-05-19 Richard Biener PR tree-optimization/61209 diff --git a/gcc/testsuite/gcc.dg/torture/pr61221.c b/gcc/testsuite/gcc.dg/torture/pr61221.c new file mode 100644 index 00000000000..2524382ba1a --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr61221.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +void __assert_fail (void); + +int **a, b, c, e, *j; +short *d, **f; + +int * +foo () +{ + *a = j; + if (!(1 & e)) + __assert_fail (); + return 0; +} + +void +bar () +{ + int *g = &b; + short **h = &d; + if ((f = &d) != h) + for (; b;) + { + int i = 1; + if (i) + g = foo (); + c = 0; + } + if (!g) + __assert_fail (); +} diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index f634f5efd29..e487d283c28 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -4010,6 +4010,15 @@ eliminate_dom_walker::before_dom_children (basic_block b) /* Mark new bb. */ el_avail_stack.safe_push (NULL_TREE); + /* If this block is not reachable do nothing. */ + edge_iterator ei; + edge e; + FOR_EACH_EDGE (e, ei, b->preds) + if (e->flags & EDGE_EXECUTABLE) + break; + if (!e) + return; + for (gsi = gsi_start_phis (b); !gsi_end_p (gsi);) { gimple stmt, phi = gsi_stmt (gsi); diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index bd603729f13..fc00682fcd8 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -4177,11 +4177,13 @@ cond_dom_walker::before_dom_children (basic_block bb) if (fail) return; - /* If any of the predecessor edges are still marked as possibly - executable consider this block reachable. */ + /* If any of the predecessor edges that do not come from blocks dominated + by us are still marked as possibly executable consider this block + reachable. */ bool reachable = bb == ENTRY_BLOCK_PTR_FOR_FN (cfun); FOR_EACH_EDGE (e, ei, bb->preds) - reachable |= (e->flags & EDGE_EXECUTABLE); + if (!dominated_by_p (CDI_DOMINATORS, e->src, bb)) + reachable |= (e->flags & EDGE_EXECUTABLE); /* If the block is not reachable all outgoing edges are not executable. */