Hello...

Le 23/05/2024 à 22:52, Andrew MacLeod a écrit :
A range-query currently provides a couple of relation query routines, plus it also provides direct access to an oracle.   This patch moves those queries into the oracle where they should be, and ands the ability to create and destroy the basic dominance oracle ranger uses.  This is the usual oracle most passes would want, and this provides full access to it if ranger has been enabled.  It also allows passes which do not use ranger to turn on an oracle and work with it.

Full documentation  for relations and the oracle can be found at: https://gcc.gnu.org/wiki/AndrewMacLeod/Relations

Moving the queries into the oracle removes the need to check for a NULL pointer on every query, and results in speeding up VRP by about 0.7%

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


(...)

diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index c2ab745a466..b275a43b679 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -437,53 +439,3 @@ global_range_query::range_of_expr (vrange &r, tree expr, 
gimple *stmt)
return true;
 }
-
-// Return any known relation between SSA1 and SSA2 before stmt S is executed.
-// If GET_RANGE is true, query the range of both operands first to ensure
-// the definitions have been processed and any relations have be created.
-
-relation_kind
-range_query::query_relation (gimple *s, tree ssa1, tree ssa2, bool get_range) 
> -{
-  if (!m_oracle || TREE_CODE (ssa1) != SSA_NAME || TREE_CODE (ssa2) != 
SSA_NAME)
-    return VREL_VARYING;
-
-  // Ensure ssa1 and ssa2 have both been evaluated.
-  if (get_range)
-    {
-      Value_Range tmp1 (TREE_TYPE (ssa1));
-      Value_Range tmp2 (TREE_TYPE (ssa2));
-      range_of_expr (tmp1, ssa1, s);
-      range_of_expr (tmp2, ssa2, s);
-    }
-  return m_oracle->query_relation (gimple_bb (s), ssa1, ssa2);
-}
-
-// Return any known relation between SSA1 and SSA2 on edge E.
-// If GET_RANGE is true, query the range of both operands first to ensure
-// the definitions have been processed and any relations have be created.
-
-relation_kind
-range_query::query_relation (edge e, tree ssa1, tree ssa2, bool get_range)
-{
-  basic_block bb;
-  if (!m_oracle || TREE_CODE (ssa1) != SSA_NAME || TREE_CODE (ssa2) != 
SSA_NAME)
-    return VREL_VARYING;
-
-  // Use destination block if it has a single predecessor, and this picks
-  // up any relation on the edge.
-  // Otherwise choose the src edge and the result is the same as on-exit.
-  if (!single_pred_p (e->dest))
-    bb = e->src;
-  else
-    bb = e->dest;
-
-  // Ensure ssa1 and ssa2 have both been evaluated.
-  if (get_range)
-    {
-      Value_Range tmp (TREE_TYPE (ssa1));
-      range_on_edge (tmp, e, ssa1);
-      range_on_edge (tmp, e, ssa2);
-    }
-  return m_oracle->query_relation (bb, ssa1, ssa2);
-}

(...)

diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index 619ee5f0867..d1081b3b3f5 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -288,6 +288,39 @@ relation_oracle::valid_equivs (bitmap b, const_bitmap 
equivs, basic_block bb)
     }
 }
+// Return any known relation between SSA1 and SSA2 before stmt S is executed.
+// If GET_RANGE is true, query the range of both operands first to ensure
+// the definitions have been processed and any relations have be created.

The method lost its argument GET_RANGE in the move from value-query.cc, so the documentation for GET_RANGE can be removed as well.

+
+relation_kind
+relation_oracle::query_relation (gimple *s, tree ssa1, tree ssa2)
+{
+  if (TREE_CODE (ssa1) != SSA_NAME || TREE_CODE (ssa2) != SSA_NAME)
+    return VREL_VARYING;
+  return query_relation (gimple_bb (s), ssa1, ssa2);
+}
+
+// Return any known relation between SSA1 and SSA2 on edge E.
+// If GET_RANGE is true, query the range of both operands first to ensure
+// the definitions have been processed and any relations have be created.

Same here.

+
+relation_kind
+relation_oracle::query_relation (edge e, tree ssa1, tree ssa2)
+{
+  basic_block bb;
+  if (TREE_CODE (ssa1) != SSA_NAME || TREE_CODE (ssa2) != SSA_NAME)
+    return VREL_VARYING;
+
+  // Use destination block if it has a single predecessor, and this picks
+  // up any relation on the edge.
+  // Otherwise choose the src edge and the result is the same as on-exit.
+  if (!single_pred_p (e->dest))
+    bb = e->src;
+  else
+    bb = e->dest;
+
+  return query_relation (bb, ssa1, ssa2);
+}
 // -------------------------------------------------------------------------
// The very first element in the m_equiv chain is actually just a summary

Reply via email to