Range_on_edge in ranger_cache should return true for all ranges.

Message ID 5d17879b-0915-74f6-cd3a-f8218bac6bc4@redhat.com
State New
Headers show
Series
  • Range_on_edge in ranger_cache should return true for all ranges.
Related show

Commit Message

Richard Biener via Gcc-patches June 17, 2021, 12:13 a.m.
This patch mostly affects an internal routine in the ranger_cache.  When 
doing the cache rework to also be a range_query object, I implemented 
range_on_edge to always return a range, but only return TRUE when the 
range was actually changed on the edge.  This was a well intention but 
misguided attempt to combine has_edge_range_p() and 
outgoing_edge_range_p ().

With the GORI engine now using the ranger_cache as a "read only"range 
query to access the cache and fold statements, range_on_edge returning 
false meant that the fold_using_range code would turn constants and 
other ssa_name ranges into VARYING because the value FALSE was returned.

This corrects that mistake, and changes range_on_edge to return TRUE 
whenever any range is calculated.

Bootstraps on  x86_64-pc-linux-gnu with no regressions.  Pushed.

Andrew

Patch

commit 8a22a10c7879109c3906e1b865c50fe236b89f41
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Wed Jun 16 11:14:36 2021 -0400

    Range_on_edge in ranger_cache should return true for all ranges.
    
    Range_on_edge was implemented in the cache to always return a range, but
    only returned true when the edge actally changed the range.
    Return true with any range that can be calculated.
    
            * gimple-range-cache.cc (ranger_cache::range_on_edge): Always return
            true when a range can be calculated.
            * gimple-range.cc (gimple_ranger::dump_bb): Check has_edge_range_p.

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 37e2acb19f9..cc2b7092dad 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -978,8 +978,7 @@  ranger_cache::range_of_expr (irange &r, tree name, gimple *stmt)
 }
 
 
-// Implement range_on_edge. Return TRUE if the edge generates a range,
-// otherwise false.. but still return a range.
+// Implement range_on_edge.  Always return the best available range.
 
  bool
  ranger_cache::range_on_edge (irange &r, edge e, tree expr)
@@ -989,14 +988,11 @@  ranger_cache::range_of_expr (irange &r, tree name, gimple *stmt)
       exit_range (r, expr, e->src);
       int_range_max edge_range;
       if (m_gori.outgoing_edge_range_p (edge_range, e, expr, *this))
-	{
-	  r.intersect (edge_range);
-	  return true;
-	}
+	r.intersect (edge_range);
+      return true;
     }
-  else
-    get_tree_range (r, expr, NULL);
-  return false;
+
+  return get_tree_range (r, expr, NULL);
 }
 
 
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 481b89b2b80..efb919f1595 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -1394,7 +1394,8 @@  gimple_ranger::dump_bb (FILE *f, basic_block bb)
       for (x = 1; x < num_ssa_names; x++)
 	{
 	  tree name = gimple_range_ssa_p (ssa_name (x));
-	  if (name && m_cache.range_on_edge (range, e, name))
+	  if (name && gori ().has_edge_range_p (name, e)
+	      && m_cache.range_on_edge (range, e, name))
 	    {
 	      gimple *s = SSA_NAME_DEF_STMT (name);
 	      // Only print the range if this is the def block, or