From: Richard Guenther Date: Mon, 10 Sep 2012 14:10:09 +0000 (+0000) Subject: re PR middle-end/54520 (ice in merge_latch_edges with -O3) X-Git-Tag: misc/gupc_5_2_0_release~290^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1779dc343a559d1d822e8cbcb998bcde049c5123;p=thirdparty%2Fgcc.git re PR middle-end/54520 (ice in merge_latch_edges with -O3) 2012-09-10 Richard Guenther PR tree-optimization/54520 * tree-ssa-threadupdate.c (def_split_header_continue_p): Properly consider sub-loops. * gcc.dg/torture/pr54520.c: New testcase. From-SVN: r191141 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6e7175afd3fd..0e0bc2bdcec5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-09-10 Richard Guenther + + PR tree-optimization/54520 + * tree-ssa-threadupdate.c (def_split_header_continue_p): + Properly consider sub-loops. + 2012-09-10 Richard Henderson * config/alpha/predicates.md (small_symbolic_operand): Disallow diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65e31bd88048..bd4b362c188a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-09-10 Richard Guenther + + PR tree-optimization/54520 + * gcc.dg/torture/pr54520.c: New testcase. + 2012-09-10 Jason Merrill PR c++/54506 diff --git a/gcc/testsuite/gcc.dg/torture/pr54520.c b/gcc/testsuite/gcc.dg/torture/pr54520.c new file mode 100644 index 000000000000..5884b2f353a1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr54520.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +char *a; +void +fn1 () +{ + char *p = a; + while (p && *p != '\0') + { + while (*p == '\t') + *p++ = '\0'; + if (*p != '\0') + p = 0; + } +} diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index 30336a18e81f..ba6d69af9428 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -846,8 +846,9 @@ static bool def_split_header_continue_p (const_basic_block bb, const void *data) { const_basic_block new_header = (const_basic_block) data; - return (bb->loop_father == new_header->loop_father - && bb != new_header); + return (bb != new_header + && (loop_depth (bb->loop_father) + >= loop_depth (new_header->loop_father))); } /* Thread jumps through the header of LOOP. Returns true if cfg changes. @@ -1031,10 +1032,11 @@ thread_through_loop_header (struct loop *loop, bool may_peel_loop_headers) nblocks = dfs_enumerate_from (header, 0, def_split_header_continue_p, bblocks, loop->num_nodes, tgt_bb); for (i = 0; i < nblocks; i++) - { - remove_bb_from_loops (bblocks[i]); - add_bb_to_loop (bblocks[i], loop_outer (loop)); - } + if (bblocks[i]->loop_father == loop) + { + remove_bb_from_loops (bblocks[i]); + add_bb_to_loop (bblocks[i], loop_outer (loop)); + } free (bblocks); /* If the new header has multiple latches mark it so. */