public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC] sched: Do not move expensive insns speculatively (PR68664)
@ 2017-01-27  0:40 Segher Boessenkool
  2017-01-27  1:12 ` Andrew Pinski
  2017-01-27 12:20 ` Richard Biener
  0 siblings, 2 replies; 18+ messages in thread
From: Segher Boessenkool @ 2017-01-27  0:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool

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).

Is there some existing way to test for "very expensive insn" or "very
expensive insn we should not speculate"?  Should there be a new hook?
Is only disallowing (FP) SQRT and DIV a good solution?


Segher


---
 gcc/sched-rgn.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index 2af3a03..6ccd973 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "sel-sched.h"
 #include "tree-pass.h"
 #include "dbgcnt.h"
+#include "rtl-iter.h"
 #include "pretty-print.h"
 #include "print-rtl.h"
 
@@ -2147,12 +2148,20 @@ 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.  */
+      subrtx_iterator::array_type array;
+      FOR_EACH_SUBRTX (iter, array, insn, NONCONST)
+        if (*iter && GET_CODE (*iter) == SQRT)
+	  return 0;
+    }
+
+  return 1;
 }
 
 /* Updates counter and other information.  Split from can_schedule_ready_p ()
-- 
1.9.3

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-01-27 22:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-27  0:40 [RFC] sched: Do not move expensive insns speculatively (PR68664) Segher Boessenkool
2017-01-27  1:12 ` Andrew Pinski
2017-01-27  1:27   ` Segher Boessenkool
2017-01-27  2:12     ` Andrew Pinski
2017-01-27 11:36       ` Ramana Radhakrishnan
2017-01-27 12:43         ` Segher Boessenkool
2017-01-27 18:11         ` Jeff Law
2017-01-27 12:45     ` Bernd Schmidt
2017-01-27 14:19       ` Segher Boessenkool
2017-01-27 18:20       ` Jeff Law
2017-01-27 12:20 ` Richard Biener
2017-01-27 12:42   ` Segher Boessenkool
2017-01-27 13:43     ` Richard Biener
2017-01-27 14:37       ` Segher Boessenkool
2017-01-27 18:08         ` Jeff Law
2017-01-27 22:04           ` Segher Boessenkool
2017-01-27 22:21             ` Jeff Law
2017-01-27 22:30               ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).