public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1438] Limit new value calculations to first order effects.
@ 2021-06-14 21:06 Andrew Macleod
  0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2021-06-14 21:06 UTC (permalink / raw)
  To: gcc-cvs

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

commit r12-1438-gecc5644fa3bc7f37eada2a3e9c627cd1918922e0
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Mon Jun 14 15:33:59 2021 -0400

    Limit new value calculations to first order effects.
    
    When utilzing poor values during propagation, we mostly care about values that
    were undefined/processed directly used in calcualting the SSA_NAME being
    processed.  2nd level derivations of such poor values rarely affect the
    inital calculation.  Leave them to when they are directly encountered.
    
            * gimple-range-cache.cc (ranger_cache::ranger_cache): Adjust.
            (ranger_cache::enable_new_values): Set to specified value and
            return the old value.
            (ranger_cache::disable_new_values): Delete.
            (ranger_cache::fill_block_cache): Disable non 1st order derived
            poor values.
            * gimple-range-cache.h (ranger_cache): Adjust prototypes.
            * gimple-range.cc (gimple_ranger::range_of_expr): Adjust.

Diff:
---
 gcc/gimple-range-cache.cc | 27 +++++++++++++--------------
 gcc/gimple-range-cache.h  |  3 +--
 gcc/gimple-range.cc       |  4 ++--
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 249515fbaf5..d9a57c294df 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -727,7 +727,7 @@ ranger_cache::ranger_cache (gimple_ranger &q) : query (q)
       if (bb)
 	m_gori.exports (bb);
     }
-  enable_new_values ();
+  enable_new_values (true);
 }
 
 ranger_cache::~ranger_cache ()
@@ -748,21 +748,15 @@ ranger_cache::dump (FILE *f)
   fprintf (f, "\n");
 }
 
-// Allow the cache to flag and query new values when propagation is forced
-// to use an unknown value.
+// Allow or disallow the cache to flag and query new values when propagation
+// is forced to use an unknown value.  The previous state is returned.
 
-void
-ranger_cache::enable_new_values ()
-{
-  m_new_value_p = true;
-}
-
-// Disable new value querying.
-
-void
-ranger_cache::disable_new_values ()
+bool
+ranger_cache::enable_new_values (bool state)
 {
-  m_new_value_p = false;
+  bool ret = m_new_value_p;
+  m_new_value_p = state;
+  return ret;
 }
 
 // Dump the caches for basic block BB to file F.
@@ -1343,7 +1337,12 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb)
 
 	  // Calculate a range at the exit from the block so the caches feeding
 	  // this block will be filled, and we'll get a "better" value.
+	  // Disallow additonal "poor values" during this phase to avoid
+	  // iterations that are unlikely to be profitable for this name.
+	  // See PR 101014.
+	  bool state = enable_new_values (false);
 	  query.range_on_exit (tmp, calc_bb, rec.calc);
+	  enable_new_values (state);
 	  
 	  // Then ask for NAME to be re-evaluated on outgoing edges and 
 	  // use any new values.
diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h
index ce4449a08db..1a2aaceb3ed 100644
--- a/gcc/gimple-range-cache.h
+++ b/gcc/gimple-range-cache.h
@@ -101,8 +101,7 @@ public:
   bool get_non_stale_global_range (irange &r, tree name);
   void set_global_range (tree name, const irange &r);
 
-  void enable_new_values ();
-  void disable_new_values ();
+  bool enable_new_values (bool state);
   non_null_ref m_non_null;
   gori_compute m_gori;
 
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index b534b8e0a2c..481b89b2b80 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -1173,9 +1173,9 @@ gimple_ranger::range_of_expr (irange &r, tree expr, gimple *stmt)
   // trigger new value calculations.  PR 100781.
   if (is_gimple_debug (stmt))
     {
-      m_cache.disable_new_values ();
+      bool state = m_cache.enable_new_values (false);
       m_cache.range_of_expr (r, expr, stmt);
-      m_cache.enable_new_values ();
+      m_cache.enable_new_values (state);
       return true;
     }
   basic_block bb = gimple_bb (stmt);


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

only message in thread, other threads:[~2021-06-14 21:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 21:06 [gcc r12-1438] Limit new value calculations to first order effects Andrew Macleod

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