From 8e9a9b014264250eeda5544cafbdc16eba9489e1 Mon Sep 17 00:00:00 2001 From: Andrey Belevantsev Date: Mon, 9 Apr 2018 12:42:25 +0300 Subject: [PATCH] re PR rtl-optimization/83913 (Compile time and memory hog w/ selective scheduling) PR rtl-optimization/83913 * sel-sched-ir.c (merge_expr_data): Choose the middle between two different sched-times when merging exprs. * gcc.dg/pr83913.c: New test. From-SVN: r259230 --- gcc/ChangeLog | 7 +++++++ gcc/sel-sched-ir.c | 8 ++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr83913.c | 26 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr83913.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 99d9ccacd36..a22c610bab7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-04-09 Andrey Belevantsev + + PR rtl-optimization/83913 + + * sel-sched-ir.c (merge_expr_data): Choose the middle between two + different sched-times when merging exprs. + 2018-04-09 Andrey Belevantsev PR rtl-optimization/83962 diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c index 987bd9f93cf..6f1e5a1f90d 100644 --- a/gcc/sel-sched-ir.c +++ b/gcc/sel-sched-ir.c @@ -1837,8 +1837,12 @@ merge_expr_data (expr_t to, expr_t from, insn_t split_point) if (EXPR_PRIORITY (to) < EXPR_PRIORITY (from)) EXPR_PRIORITY (to) = EXPR_PRIORITY (from); - if (EXPR_SCHED_TIMES (to) > EXPR_SCHED_TIMES (from)) - EXPR_SCHED_TIMES (to) = EXPR_SCHED_TIMES (from); + /* We merge sched-times half-way to the larger value to avoid the endless + pipelining of unneeded insns. The average seems to be good compromise + between pipelining opportunities and avoiding extra work. */ + if (EXPR_SCHED_TIMES (to) != EXPR_SCHED_TIMES (from)) + EXPR_SCHED_TIMES (to) = ((EXPR_SCHED_TIMES (from) + EXPR_SCHED_TIMES (to) + + 1) / 2); if (EXPR_ORIG_BB_INDEX (to) != EXPR_ORIG_BB_INDEX (from)) EXPR_ORIG_BB_INDEX (to) = 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 91a1a2f8973..2de94af83e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-09 Andrey Belevantsev + + PR rtl-optimization/83913 + * gcc.dg/pr83913.c: New test. + 2018-04-09 Andrey Belevantsev PR rtl-optimization/83962 diff --git a/gcc/testsuite/gcc.dg/pr83913.c b/gcc/testsuite/gcc.dg/pr83913.c new file mode 100644 index 00000000000..c898d71a261 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83913.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -funroll-all-loops -fselective-scheduling -fsel-sched-pipelining -fschedule-insns -fno-dce -fno-forward-propagate -fno-rerun-cse-after-loop -fno-web" } */ + +int jo, z4; + +int +be (long unsigned int l7, int nt) +{ + int en; + + jo = l7; + for (en = 0; en < 24; ++en) + { + jo = (jo / z4) * (!!jo >= ((!!nt) & 2)); + if (jo == 0) + nt = 0; + else + { + nt = z4; + ++z4; + nt = (long unsigned int) nt == (l7 + 1); + } + } + + return nt; +} -- 2.30.2