From 6fb8055edde15e304f77fbac2c2f317a5a44d6e9 Mon Sep 17 00:00:00 2001 From: Andrey Belevantsev Date: Tue, 2 Apr 2019 18:45:57 +0300 Subject: [PATCH] sel-sched: skip outer loop in get_all_loop_exits (PR 84206) 2019-04-02 Andrey Belevantsev PR rtl-optimization/84206 * sel-sched-ir.h (get_all_loop_exits): Avoid the outer loop when iterating over loop headers. * gcc.dg/pr84206.c: New test. From-SVN: r270096 --- gcc/ChangeLog | 6 ++++++ gcc/sel-sched-ir.h | 10 +++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr84206.c | 24 ++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr84206.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e02099715e3..f36a769e354 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-04-02 Andrey Belevantsev + + PR rtl-optimization/84206 + * sel-sched-ir.h (get_all_loop_exits): Avoid the outer loop when + iterating over loop headers. + 2019-04-02 Andrey Belevantsev PR rtl-optimization/85876 diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h index 1d9c04a322a..5dd273f40a4 100644 --- a/gcc/sel-sched-ir.h +++ b/gcc/sel-sched-ir.h @@ -1144,6 +1144,7 @@ get_all_loop_exits (basic_block bb) struct loop *this_loop; struct loop *pred_loop = NULL; int i; + unsigned this_depth; edge e; for (this_loop = bb->loop_father; @@ -1155,11 +1156,14 @@ get_all_loop_exits (basic_block bb) gcc_assert (this_loop != NULL); exits = get_loop_exit_edges_unique_dests (this_loop); + this_depth = loop_depth (this_loop); - /* Traverse all loop headers. */ + /* Traverse all loop headers. Be careful not to go back + to the outer loop's header (see PR 84206). */ for (i = 0; exits.iterate (i, &e); i++) - if (in_current_region_p (e->dest) - || inner_loop_header_p (e->dest)) + if ((in_current_region_p (e->dest) + || (inner_loop_header_p (e->dest))) + && loop_depth (e->dest->loop_father) >= this_depth) { vec next_exits = get_all_loop_exits (e->dest); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 04d9de44734..6e26cbe272d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-02 Andrey Belevantsev + + PR rtl-optimization/84206 + * gcc.dg/pr84206.c: New test. + 2019-04-02 Andrey Belevantsev PR rtl-optimization/85876 diff --git a/gcc/testsuite/gcc.dg/pr84206.c b/gcc/testsuite/gcc.dg/pr84206.c new file mode 100644 index 00000000000..b4ac9c24c78 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr84206.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fno-forward-propagate -fno-tree-fre -w" } */ + +long long unsigned int ao; +int hk; + +void +b8 (void) +{ + int *w9; + + c8: + ao = 0; + w9 = &ao; + for (;;) + for (hk = 0; hk < 1; ++hk) + for (ao = 0; ao < 4; ++ao) + { + int f4 = (ao != 0) ? *w9 : hk; + + if (f4 != 0) + goto c8; + } +} -- 2.30.2