public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: gcc-patches@gcc.gnu.org
Cc: "Vladimir N. Makarov" <vmakarov@redhat.com>
Subject: [PATCH] sel-sched: Don't clone CALLs (PR48273)
Date: Thu, 07 Apr 2011 17:30:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1104072116220.17990@monoid.intra.ispras.ru> (raw)

Hi,

Selective scheduler does not explicitly forbid creating bookkeeping copies of
CALLs, but an assert in create_copy_of_insn_rtx does not expect a CALL.  Since
there's little benefit from aggressive scheduling of CALLs, it makes sense to
restrict it so that CALLs cannot be duplicated.

This patch makes CALLs non-clonable by adding an explicit check in additional
to other non-clonable insns (ASMs, instructions that are a part of
SCHED_GROUPs, etc.).  We also need to forbid pipelining of loops that have no
exit edges, since our check for whether a motion would create bookkeeping does
not work in that case (it's one of the solutions; the other is to fixup
remove_insns_that_need_bookkeeping function, but this one is simpler and
faster).


	PR target/48273
	* cfgloop.h (loop_has_exit_edges): New helper.
	* sel-sched-ir.c (init_global_and_expr_for_insn): Make CALLs
	non-clonable.
	(sel_setup_region_sched_flags): Don't pipeline loops that have no
	exit edges.

testsuite:
	* g++.dg/opt/pr48273.C: New.

diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index f7bb134..0ff44de 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -443,6 +443,14 @@ loop_outer (const struct loop *loop)
   return VEC_index (loop_p, loop->superloops, n - 1);
 }
 
+/* Returns true if LOOP has at least one exit edge.  */
+
+static inline bool
+loop_has_exit_edges (const struct loop *loop)
+{
+  return loop->exits->next->e != NULL;
+}
+
 /* Returns the list of loops in current_loops.  */
 
 static inline VEC (loop_p, gc) *
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 67484dd..95c1431 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -2905,6 +2905,7 @@ init_global_and_expr_for_insn (insn_t insn)
       if (CANT_MOVE (insn)
           || INSN_ASM_P (insn)
           || SCHED_GROUP_P (insn)
+	  || CALL_P (insn)
           /* Exception handling insns are always unique.  */
           || (cfun->can_throw_non_call_exceptions && can_throw_internal (insn))
           /* TRAP_IF though have an INSN code is control_flow_insn_p ().  */
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 0e8173b..fb1a026 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -6781,7 +6781,8 @@ sel_setup_region_sched_flags (void)
   bookkeeping_p = 1;
   pipelining_p = (bookkeeping_p
                   && (flag_sel_sched_pipelining != 0)
-		  && current_loop_nest != NULL);
+		  && current_loop_nest != NULL
+		  && loop_has_exit_edges (current_loop_nest));
   max_insns_to_rename = PARAM_VALUE (PARAM_SELSCHED_INSNS_TO_RENAME);
   max_ws = MAX_WS;
 }
diff --git a/gcc/testsuite/g++.dg/opt/pr48273.C b/gcc/testsuite/g++.dg/opt/pr48273.C
new file mode 100644
index 0000000..4c5108b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr48273.C
@@ -0,0 +1,10 @@
+// { dg-do compile { target x86_64-*-* } }
+// { dg-options "-fschedule-insns2 -fsel-sched-pipelining -fselective-scheduling2 -funroll-all-loops -march=core2" }
+
+void bar ();
+
+void foo ()
+{
+  for (;;)
+    bar ();
+}

             reply	other threads:[~2011-04-07 17:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07 17:30 Alexander Monakov [this message]
2011-04-07 20:13 ` Vladimir Makarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1104072116220.17990@monoid.intra.ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=vmakarov@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).