public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] rtl-ssa: Extend make_uses_available
@ 2023-10-30 18:34 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-10-30 18:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8c28b57c64af355ec19916aa828b3d5b813ea567

commit 8c28b57c64af355ec19916aa828b3d5b813ea567
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Wed Oct 25 10:39:53 2023 +0100

    rtl-ssa: Extend make_uses_available
    
    The first in-tree use of RTL-SSA was fwprop, and one of the goals
    was to make the fwprop rewrite preserve the old behaviour as far
    as possible.  The switch to RTL-SSA was supposed to be a pure
    infrastructure change.  So RTL-SSA has various FIXMEs for things
    that were artifically limited to faciliate the old-fwprop vs.
    new-fwprop comparison.
    
    One of the things that fwprop wants to do is extend live ranges, and
    function_info::make_use_available tried to keep within the cases that
    old fwprop could handle.
    
    Since the information is built in extended basic blocks, it's easy
    to handle intra-EBB queries directly.  This patch does that, and
    removes the associated FIXME.
    
    To get a flavour for how much difference this makes, I tried compiling
    the testsuite at -Os for at least one target per supported CPU and OS.
    For most targets, only a handful of tests changed, but the vast majority
    of changes were positive.  The only target that seemed to benefit
    significantly was i686-apple-darwin.
    
    The main point of the patch is to remove the FIXME and to enable
    the upcoming post-RA late-combine pass to handle more cases.
    
    gcc/
            * rtl-ssa/functions.h (function_info::remains_available_at_insn):
            New member function.
            * rtl-ssa/accesses.cc (function_info::remains_available_at_insn):
            Likewise.
            (function_info::make_use_available): Avoid false negatives for
            queries within an EBB.
    
    (cherry picked from commit 39cac7c31484ef6aefec18b2a59a99e1b74940fe)

Diff:
---
 gcc/rtl-ssa/accesses.cc | 37 +++++++++++++++++++++++++++++++++++--
 gcc/rtl-ssa/functions.h |  4 ++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc
index 3f030bb166f0..0fa91fb603d2 100644
--- a/gcc/rtl-ssa/accesses.cc
+++ b/gcc/rtl-ssa/accesses.cc
@@ -1295,6 +1295,33 @@ function_info::insert_temp_clobber (obstack_watermark &watermark,
   return insert_access (watermark, clobber, old_defs);
 }
 
+// See the comment above the declaration.
+bool
+function_info::remains_available_at_insn (const set_info *set,
+					  insn_info *insn)
+{
+  auto *ebb = set->ebb ();
+  gcc_checking_assert (ebb == insn->ebb ());
+
+  def_info *next_def = set->next_def ();
+  if (next_def && *next_def->insn () < *insn)
+    return false;
+
+  if (HARD_REGISTER_NUM_P (set->regno ())
+      && TEST_HARD_REG_BIT (m_clobbered_by_calls, set->regno ()))
+    for (ebb_call_clobbers_info *call_group : ebb->call_clobbers ())
+      {
+	if (!call_group->clobbers (set->resource ()))
+	  continue;
+
+	insn_info *call_insn = next_call_clobbers (*call_group, insn);
+	if (call_insn && *call_insn < *insn)
+	  return false;
+      }
+
+  return true;
+}
+
 // See the comment above the declaration.
 bool
 function_info::remains_available_on_exit (const set_info *set, bb_info *bb)
@@ -1346,14 +1373,20 @@ function_info::make_use_available (use_info *use, bb_info *bb,
   if (is_single_dominating_def (def))
     return use;
 
-  // FIXME: Deliberately limited for fwprop compatibility testing.
+  if (def->ebb () == bb->ebb ())
+    {
+      if (remains_available_at_insn (def, bb->head_insn ()))
+	return use;
+      return nullptr;
+    }
+
   basic_block cfg_bb = bb->cfg_bb ();
   bb_info *use_bb = use->bb ();
   if (single_pred_p (cfg_bb)
       && single_pred (cfg_bb) == use_bb->cfg_bb ()
       && remains_available_on_exit (def, use_bb))
     {
-      if (def->ebb () == bb->ebb () || will_be_debug_use)
+      if (will_be_debug_use)
 	return use;
 
       resource_info resource = use->resource ();
diff --git a/gcc/rtl-ssa/functions.h b/gcc/rtl-ssa/functions.h
index bb709153237e..d6c0db862224 100644
--- a/gcc/rtl-ssa/functions.h
+++ b/gcc/rtl-ssa/functions.h
@@ -121,6 +121,10 @@ public:
   // scope until the change has been aborted or successfully completed.
   obstack_watermark new_change_attempt () { return &m_temp_obstack; }
 
+  // SET and INSN belong to the same EBB, with SET occuring before INSN.
+  // Return true if SET is still available at INSN.
+  bool remains_available_at_insn (const set_info *set, insn_info *insn);
+
   // SET either occurs in BB or is known to be available on entry to BB.
   // Return true if it is also available on exit from BB.  (The value
   // might or might not be live.)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-30 18:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-30 18:34 [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] rtl-ssa: Extend make_uses_available Jeff Law

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