diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cc84f50f3db..24efa857d85 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2012-04-11 Richard Guenther + + PR tree-optimization/52912 + * tree-ssa-threadupdate.c (thread_block): Tell the cfg + manipulation code we are threading through a loop header + to an exit destination. + 2012-04-10 Manuel López-Ibáñez * tree.h (warn_if_unused_value): Move declaration from here. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index def1d1fb642..08293166910 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-04-11 Richard Guenther + + PR tree-optimization/52912 + * gcc.dg/torture/pr52912.c: New testcase. + 2010-04-10 Michael Matz * gcc.dg/vect/vect-outer-1-big-array.c: Adjust. diff --git a/gcc/testsuite/gcc.dg/torture/pr52912.c b/gcc/testsuite/gcc.dg/torture/pr52912.c new file mode 100644 index 00000000000..3ae57588f26 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr52912.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int a, b, c; +static int +fn1 (p1) +{ +lbl_549: + if (p1) + goto lbl_549; + return 0; +} + +void +fn2 () +{ + b = (c && a) > fn1 (c) >= c; +} diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index 687eee0485a..018092a7a3a 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -661,6 +661,13 @@ thread_block (basic_block bb, bool noloop_only) /* We do not update dominance info. */ free_dominance_info (CDI_DOMINATORS); + /* We know we only thread through the loop header to loop exits. + Let the basic block duplication hook know we are not creating + a multiple entry loop. */ + if (noloop_only + && bb == bb->loop_father->header) + set_loop_copy (bb->loop_father, loop_outer (bb->loop_father)); + /* Now create duplicates of BB. Note that for a block with a high outgoing degree we can waste @@ -692,6 +699,10 @@ thread_block (basic_block bb, bool noloop_only) htab_delete (redirection_data); redirection_data = NULL; + if (noloop_only + && bb == bb->loop_father->header) + set_loop_copy (bb->loop_father, NULL); + /* Indicate to our caller whether or not any jumps were threaded. */ return local_info.jumps_threaded; }