public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Improve splitX passes management
Date: Thu, 06 Feb 2020 11:13:00 -0000	[thread overview]
Message-ID: <CAFULd4ZFo0R5Em=_3O4AhEC-pg=-rgiTv01=5rLwRPgjMCiWBQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]

The names of split_before_sched2 ("split4") and split_before_regstack
("split3") do not reflect their insertion point in the sequence of passes,
where split_before_regstack follows split_before_sched2. Reorder the code
and rename the passes to reflect the reality.

split_before_regstack pass does not need to run if split_before_sched2 pass
was already performed. Introduce enable_split_before_sched2 function to
simplify gating functions of these two passes.

There is no need for a separate rest_of_handle_split_before_sched2.
split_all_insns can be called unconditionally from
pass_split_before_sched2::execute, since the corresponding gating function
determines if the pass is executed or not.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

2020-02-06  Uroš Bizjak  <ubizjak@gmail.com>

    * recog.c: Move pass_split_before_sched2 code in front of
    pass_split_before_regstack.
    (pass_data_split_before_sched2): Rename pass to split3 from split4.
    (pass_data_split_before_regstack): Rename pass to split4 from split3.
    (rest_of_handle_split_before_sched2): Remove.
    (pass_split_before_sched2::execute): Unconditionally call
    split_all_insns.
    (enable_split_before_sched2): New function.
    (pass_split_before_sched2::gate): Use enable_split_before_sched2.
    (pass_split_before_regstack::gate): Ditto.
    * config/nds32/nds32.c (nds32_split_double_word_load_store_p):
    Update name check for renamed split4 pass.
    * config/sh/sh.c (register_sh_passes): Update pass insertion
    point for renamed split4 pass.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 5144 bytes --]

diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c
index 625fa8ce7db8..acf13715d830 100644
--- a/gcc/config/nds32/nds32.c
+++ b/gcc/config/nds32/nds32.c
@@ -5496,7 +5496,7 @@ nds32_split_double_word_load_store_p(rtx *operands, bool load_p)
     return false;
 
   const char *pass_name = current_pass->name;
-  if (pass_name && ((strcmp (pass_name, "split4") == 0)
+  if (pass_name && ((strcmp (pass_name, "split3") == 0)
 		     || (strcmp (pass_name, "split5") == 0)))
     return !satisfies_constraint_Da (mem) || MEM_VOLATILE_P (mem);
 
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 3439f1663830..a178cfd3b9c9 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -800,7 +800,7 @@ register_sh_passes (void)
   /* Run sh_treg_combine pass after register allocation and basic block
      reordering as this sometimes creates new opportunities.  */
   register_pass (make_pass_sh_treg_combine (g, true, "sh_treg_combine3"),
-		 PASS_POS_INSERT_AFTER, "split4", 1);
+		 PASS_POS_INSERT_AFTER, "split3", 1);
 
   /* Optimize sett and clrt insns, by e.g. removing them if the T bit value
      is known after a conditional branch.
diff --git a/gcc/recog.c b/gcc/recog.c
index 5790a58a9114..8c098cf5b0fe 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -3943,9 +3943,19 @@ make_pass_split_after_reload (gcc::context *ctxt)
   return new pass_split_after_reload (ctxt);
 }
 
+static bool
+enable_split_before_sched2 (void)
+{
+#ifdef INSN_SCHEDULING
+  return optimize > 0 && flag_schedule_insns_after_reload;
+#else
+  return false;
+#endif
+}
+
 namespace {
 
-const pass_data pass_data_split_before_regstack =
+const pass_data pass_data_split_before_sched2 =
 {
   RTL_PASS, /* type */
   "split3", /* name */
@@ -3958,61 +3968,38 @@ const pass_data pass_data_split_before_regstack =
   0, /* todo_flags_finish */
 };
 
-class pass_split_before_regstack : public rtl_opt_pass
+class pass_split_before_sched2 : public rtl_opt_pass
 {
 public:
-  pass_split_before_regstack (gcc::context *ctxt)
-    : rtl_opt_pass (pass_data_split_before_regstack, ctxt)
+  pass_split_before_sched2 (gcc::context *ctxt)
+    : rtl_opt_pass (pass_data_split_before_sched2, ctxt)
   {}
 
   /* opt_pass methods: */
-  virtual bool gate (function *);
+  virtual bool gate (function *)
+    {
+      return enable_split_before_sched2 ();
+    }
+
   virtual unsigned int execute (function *)
     {
       split_all_insns ();
       return 0;
     }
 
-}; // class pass_split_before_regstack
-
-bool
-pass_split_before_regstack::gate (function *)
-{
-#if HAVE_ATTR_length && defined (STACK_REGS)
-  /* If flow2 creates new instructions which need splitting
-     and scheduling after reload is not done, they might not be
-     split until final which doesn't allow splitting
-     if HAVE_ATTR_length.  */
-# ifdef INSN_SCHEDULING
-  return !optimize || !flag_schedule_insns_after_reload;
-# else
-  return true;
-# endif
-#else
-  return false;
-#endif
-}
+}; // class pass_split_before_sched2
 
 } // anon namespace
 
 rtl_opt_pass *
-make_pass_split_before_regstack (gcc::context *ctxt)
-{
-  return new pass_split_before_regstack (ctxt);
-}
-
-static unsigned int
-rest_of_handle_split_before_sched2 (void)
+make_pass_split_before_sched2 (gcc::context *ctxt)
 {
-#ifdef INSN_SCHEDULING
-  split_all_insns ();
-#endif
-  return 0;
+  return new pass_split_before_sched2 (ctxt);
 }
 
 namespace {
 
-const pass_data pass_data_split_before_sched2 =
+const pass_data pass_data_split_before_regstack =
 {
   RTL_PASS, /* type */
   "split4", /* name */
@@ -4025,36 +4012,43 @@ const pass_data pass_data_split_before_sched2 =
   0, /* todo_flags_finish */
 };
 
-class pass_split_before_sched2 : public rtl_opt_pass
+class pass_split_before_regstack : public rtl_opt_pass
 {
 public:
-  pass_split_before_sched2 (gcc::context *ctxt)
-    : rtl_opt_pass (pass_data_split_before_sched2, ctxt)
+  pass_split_before_regstack (gcc::context *ctxt)
+    : rtl_opt_pass (pass_data_split_before_regstack, ctxt)
   {}
 
   /* opt_pass methods: */
-  virtual bool gate (function *)
-    {
-#ifdef INSN_SCHEDULING
-      return optimize > 0 && flag_schedule_insns_after_reload;
-#else
-      return false;
-#endif
-    }
-
+  virtual bool gate (function *);
   virtual unsigned int execute (function *)
     {
-      return rest_of_handle_split_before_sched2 ();
+      split_all_insns ();
+      return 0;
     }
 
-}; // class pass_split_before_sched2
+}; // class pass_split_before_regstack
+
+bool
+pass_split_before_regstack::gate (function *)
+{
+#if HAVE_ATTR_length && defined (STACK_REGS)
+  /* If flow2 creates new instructions which need splitting
+     and scheduling after reload is not done, they might not be
+     split until final which doesn't allow splitting
+     if HAVE_ATTR_length.  */
+  return !enable_split_before_sched2 ();
+#else
+  return false;
+#endif
+}
 
 } // anon namespace
 
 rtl_opt_pass *
-make_pass_split_before_sched2 (gcc::context *ctxt)
+make_pass_split_before_regstack (gcc::context *ctxt)
 {
-  return new pass_split_before_sched2 (ctxt);
+  return new pass_split_before_regstack (ctxt);
 }
 
 namespace {

             reply	other threads:[~2020-02-06 11:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 11:13 Uros Bizjak [this message]
2020-02-07 16:41 ` Segher Boessenkool
2020-02-08 10:54   ` Uros Bizjak
2020-02-08 17:47     ` Segher Boessenkool

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='CAFULd4ZFo0R5Em=_3O4AhEC-pg=-rgiTv01=5rLwRPgjMCiWBQ@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).