public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1653] Calculate a global definition if one has not been registered.
Date: Fri, 18 Jun 2021 21:44:44 +0000 (GMT)	[thread overview]
Message-ID: <20210618214444.05BB0394AC20@sourceware.org> (raw)

https://gcc.gnu.org/g:cb448ade74da1de1633e6ed97f8c5ecbac24b27a

commit r12-1653-gcb448ade74da1de1633e6ed97f8c5ecbac24b27a
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Fri Jun 18 12:52:10 2021 -0400

    Calculate a global definition if one has not been registered.
    
    With poor values gone, Pick up range restrictions from statements
    by folding them with global cache values.
    
            * gimple-range-cache.cc (ranger_cache::range_of_def):  Calculate
            a range if global is not available.
            (ranger_cache::entry_range): Fallback to range_of_def.
            * gimple-range-cache.h (range_of_def): Adjust prototype.

Diff:
---
 gcc/gimple-range-cache.cc | 24 +++++++++++++++---------
 gcc/gimple-range-cache.h  |  2 +-
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index c85b299d13e..def604dc149 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -824,19 +824,27 @@ ranger_cache::set_global_range (tree name, const irange &r)
 //  of an ssa_name in any given basic block.  Note, this does no additonal
 //  lookups, just accesses the data that is already known.
 
-// Get the range of NAME when the def occurs in block BB
+// Get the range of NAME when the def occurs in block BB.  If BB is NULL
+// get the best global value available.
 
 void
 ranger_cache::range_of_def (irange &r, tree name, basic_block bb)
 {
   gcc_checking_assert (gimple_range_ssa_p (name));
-  gcc_checking_assert (bb == gimple_bb (SSA_NAME_DEF_STMT (name)));
+  gcc_checking_assert (!bb || bb == gimple_bb (SSA_NAME_DEF_STMT (name)));
 
   // Pick up the best global range available.
   if (!m_globals.get_global_range (r, name))
-    r = gimple_range_global (name);
+    {
+      // If that fails, try to calculate the range using just global values.
+      gimple *s = SSA_NAME_DEF_STMT (name);
+      if (gimple_get_lhs (s) == name)
+	fold_range (r, s, get_global_range_query ());
+      else
+	r = gimple_range_global (name);
+    }
 
-  if (r.varying_p () && m_non_null.non_null_deref_p (name, bb, false) &&
+  if (bb && r.varying_p () && m_non_null.non_null_deref_p (name, bb, false) &&
       !cfun->can_throw_non_call_exceptions)
     r = range_nonzero (TREE_TYPE (name));
 }
@@ -853,12 +861,10 @@ ranger_cache::entry_range (irange &r, tree name, basic_block bb)
     }
 
   // Look for the on-entry value of name in BB from the cache.
+  // Otherwise pick up the best available global value.
   if (!m_on_entry.get_bb_range (r, name, bb))
-    {
-      // Try to pick up any known global value.
-      if (!m_globals.get_global_range (r, name))
-	r = gimple_range_global (name);
-    }
+    range_of_def (r, name);
+
   // Check if pointers have any non-null dereferences.  Non-call
   // exceptions mean we could throw in the middle of the block, so just
   // punt for now on those.
diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h
index e67af68f30b..04150ea54a8 100644
--- a/gcc/gimple-range-cache.h
+++ b/gcc/gimple-range-cache.h
@@ -115,7 +115,7 @@ private:
   void fill_block_cache (tree name, basic_block bb, basic_block def_bb);
   void propagate_cache (tree name);
 
-  void range_of_def (irange &r, tree name, basic_block bb);
+  void range_of_def (irange &r, tree name, basic_block bb = NULL);
   void entry_range (irange &r, tree expr, basic_block bb);
   void exit_range (irange &r, tree expr, basic_block bb);


                 reply	other threads:[~2021-06-18 21:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210618214444.05BB0394AC20@sourceware.org \
    --to=amacleod@gcc.gnu.org \
    --cc=gcc-cvs@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).