From: Richard Biener Date: Tue, 25 Jul 2017 13:24:51 +0000 (+0000) Subject: re PR tree-optimization/81455 (Compile-time hog w/ -O1 -funswitch-loops) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1aa54f90e68dc927e80e14c7e4bf9b42525e3c76;p=gcc.git re PR tree-optimization/81455 (Compile-time hog w/ -O1 -funswitch-loops) 2017-07-25 Richard Biener PR tree-optimization/81455 * tree-ssa-loop-unswitch.c (find_loop_guard): Make sure to not walk in cycles when looking for guards. * gcc.dg/pr81455.c: New testcase. From-SVN: r250518 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cc4bcddda52..4597d3b2f57 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-07-25 Richard Biener + + PR tree-optimization/81455 + * tree-ssa-loop-unswitch.c (find_loop_guard): Make sure to + not walk in cycles when looking for guards. + 2017-07-25 Richard Biener PR tree-optimization/81529 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e28a732f2ef..0aee7d90946 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-25 Richard Biener + + PR tree-optimization/81455 + * gcc.dg/pr81455.c: New testcase. + 2017-07-25 Richard Biener PR tree-optimization/81529 diff --git a/gcc/testsuite/gcc.dg/pr81455.c b/gcc/testsuite/gcc.dg/pr81455.c new file mode 100644 index 00000000000..8ab88639ee8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81455.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -funswitch-loops" } */ + +void +jh (unsigned int aw, int sn) +{ + int xs; + + for (xs = 0; xs < 1; ++xs) + aw &= 1; + + while (aw < 1 || ++sn < 1) + { + } +} diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 204cd0d0645..57aba4f1dd0 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -582,8 +582,9 @@ find_loop_guard (struct loop *loop) gcond *cond; do { + basic_block next = NULL; if (single_succ_p (header)) - header = single_succ (header); + next = single_succ (header); else { cond = dyn_cast (last_stmt (header)); @@ -593,12 +594,16 @@ find_loop_guard (struct loop *loop) /* Make sure to skip earlier hoisted guards that are left in place as if (true). */ if (gimple_cond_true_p (cond)) - header = te->dest; + next = te->dest; else if (gimple_cond_false_p (cond)) - header = fe->dest; + next = fe->dest; else break; } + /* Never traverse a backedge. */ + if (header->loop_father->header == next) + return NULL; + header = next; } while (1); if (!flow_bb_inside_loop_p (loop, te->dest)