From: Richard Biener Date: Tue, 9 Aug 2016 07:40:50 +0000 (+0000) Subject: re PR tree-optimization/71802 (gcc ICE at -O3 on valid code on x86_64-linux-gnu in... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=50bf47fdc08807bf8fc0362d677c8fc7dd4514b0;p=gcc.git re PR tree-optimization/71802 (gcc ICE at -O3 on valid code on x86_64-linux-gnu in expand_LOOP_VECTORIZED) 2016-08-09 Richard Biener PR tree-optimization/71802 * tree-cfgcleanup.c (cleanup_tree_cfg_bb): Make sure to catch all merge opportunities with the predecessor. * gcc.dg/torture/pr71802.c: New testcase. From-SVN: r239274 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eb0dc1d014e..2d96f88466a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-08-09 Richard Biener + + PR tree-optimization/71802 + * tree-cfgcleanup.c (cleanup_tree_cfg_bb): Make sure to catch + all merge opportunities with the predecessor. + 2016-08-09 Richard Biener PR ipa/68273 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f560fe45433..9ba1052e768 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-08-09 Richard Biener + + PR tree-optimization/71802 + * gcc.dg/torture/pr71802.c: New testcase. + 2016-08-09 Jakub Jelinek PR c++/72809 diff --git a/gcc/testsuite/gcc.dg/torture/pr71802.c b/gcc/testsuite/gcc.dg/torture/pr71802.c new file mode 100644 index 00000000000..0dd14671c51 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr71802.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ + +int b, c; +long d, f; +void fn1() +{ + char g; + long long h = 0; + int *i; + if (0) { +L2: + b && (b = f); + d = 3; + for (; d;) { + char *j = &g; + c = *j = 0; +L3: + *j %= b; + for (; g <= 4;) + ; + } + goto L2; + } + for (; *i; *i = 1) { + if ((h -= 4) == (h != (b ?: d))) { + g = 3; + goto L3; + } + i = (int *)&h; + *i = f; + i = (int *)&f; + if ((h && 6) - (h = 0)) + goto L2; + } + for (; d;) + goto L3; +} diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index ab8a9139f76..3fe0d3e8994 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -641,24 +641,25 @@ cleanup_tree_cfg_bb (basic_block bb) && remove_forwarder_block (bb)) return true; + /* If there is a merge opportunity with the predecessor + do nothing now but wait until we process the predecessor. + This happens when we visit BBs in a non-optimal order and + avoids quadratic behavior with adjusting stmts BB pointer. */ + if (single_pred_p (bb) + && can_merge_blocks_p (single_pred (bb), bb)) + /* But make sure we _do_ visit it. When we remove unreachable paths + ending in a backedge we fail to mark the destinations predecessors + as changed. */ + bitmap_set_bit (cfgcleanup_altered_bbs, single_pred (bb)->index); + /* Merging the blocks may create new opportunities for folding conditional branches (due to the elimination of single-valued PHI nodes). */ - if (single_succ_p (bb) - && can_merge_blocks_p (bb, single_succ (bb))) + else if (single_succ_p (bb) + && can_merge_blocks_p (bb, single_succ (bb))) { - /* If there is a merge opportunity with the predecessor - do nothing now but wait until we process the predecessor. - This happens when we visit BBs in a non-optimal order and - avoids quadratic behavior with adjusting stmts BB pointer. */ - if (single_pred_p (bb) - && can_merge_blocks_p (single_pred (bb), bb)) - ; - else - { - merge_blocks (bb, single_succ (bb)); - return true; - } + merge_blocks (bb, single_succ (bb)); + return true; } return false;