diff options
author | Segher Boessenkool <segher@kernel.crashing.org> | 2017-02-06 20:19:49 +0100 |
---|---|---|
committer | Segher Boessenkool <segher@gcc.gnu.org> | 2017-02-06 20:19:49 +0100 |
commit | 176274c9bf515f3b71f00b2be71a9ee4771b271f (patch) | |
tree | eebb74792325dc6a931fd34554fc77bf0e7a321a /gcc/sched-rgn.c | |
parent | 2568d8a1f6d3912e53c457a1ea080050a834cf32 (diff) | |
download | gcc-176274c9bf515f3b71f00b2be71a9ee4771b271f.zip gcc-176274c9bf515f3b71f00b2be71a9ee4771b271f.tar.gz gcc-176274c9bf515f3b71f00b2be71a9ee4771b271f.tar.bz2 |
sched: Do not move expensive insns speculatively (PR68664)
Scheduling should never move very expensive instructions to places they
are executed more frequently. This patch fixes that, reducing the
execution time of c-ray by over 40% (I tested on a BE Power7 system).
This introduces a new target hook sched.can_speculate_insn which returns
whether the scheduler is allowed to speculate a given instruction. The
rs6000 implementation disallows all divide and square root instructions.
PR rtl-optimization/68664
* target.def (can_speculate_insn): New hook.
* doc/tm.texi.in (TARGET_SCHED_CAN_SPECULATE_INSN): New hook.
* doc/tm.texi: Regenerate.
* sched-rgn.c (can_schedule_ready_p): Use the new hook.
* config/rs6000/rs6000.c (TARGET_SCHED_CAN_SPECULATE_INSN): New macro.
(rs6000_sched_can_speculate_insn): New function.
From-SVN: r245215
Diffstat (limited to 'gcc/sched-rgn.c')
-rw-r--r-- | gcc/sched-rgn.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c index 2af3a03..a09fc5d 100644 --- a/gcc/sched-rgn.c +++ b/gcc/sched-rgn.c @@ -2147,12 +2147,19 @@ static int can_schedule_ready_p (rtx_insn *insn) { /* An interblock motion? */ - if (INSN_BB (insn) != target_bb - && IS_SPECULATIVE_INSN (insn) - && !check_live (insn, INSN_BB (insn))) - return 0; - else - return 1; + if (INSN_BB (insn) != target_bb && IS_SPECULATIVE_INSN (insn)) + { + /* Cannot schedule this insn unless all operands are live. */ + if (!check_live (insn, INSN_BB (insn))) + return 0; + + /* Should not move expensive instructions speculatively. */ + if (GET_CODE (PATTERN (insn)) != CLOBBER + && !targetm.sched.can_speculate_insn (insn)) + return 0; + } + + return 1; } /* Updates counter and other information. Split from can_schedule_ready_p () |