aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-query.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2021-06-17 10:19:31 -0400
committerAndrew MacLeod <amacleod@redhat.com>2021-06-22 08:11:44 -0400
commit3aaa69e5f30e1904d7ca2bb711b1cb0c62b6895f (patch)
tree1caa5a6f5da442c5a2f837f34ea20d3b41d85996 /gcc/value-query.cc
parenta2ef8395fa970498985764514044e5fd00f7d5c0 (diff)
downloadgcc-3aaa69e5f30e1904d7ca2bb711b1cb0c62b6895f.zip
gcc-3aaa69e5f30e1904d7ca2bb711b1cb0c62b6895f.tar.gz
gcc-3aaa69e5f30e1904d7ca2bb711b1cb0c62b6895f.tar.bz2
Initial value-relation code.
This code provides a both an equivalence and relation oracle which can be accessed via a range_query object. This initial code drop includes the oracles and access them, but does not utilize them yet. * Makefile.in (OBJS): Add value-relation.o. * gimple-range.h: Adjust include files. * tree-data-ref.c: Adjust include file order. * value-query.cc (range_query::get_value_range): Default to no oracle. (range_query::query_relation): New. (range_query::query_relation): New. * value-query.h (class range_query): Adjust. * value-relation.cc: New. * value-relation.h: New.
Diffstat (limited to 'gcc/value-query.cc')
-rw-r--r--gcc/value-query.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index 93609f3..17dfdb1 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -174,6 +174,7 @@ range_query::get_value_range (const_tree expr, gimple *stmt)
range_query::range_query ()
{
equiv_alloc = new equiv_allocator;
+ m_oracle = NULL;
}
range_query::~range_query ()
@@ -452,3 +453,52 @@ global_range_query::range_of_expr (irange &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 defintions have been processed and any relations have be created.
+
+relation_kind
+range_query::query_relation (gimple *s, tree ssa1, tree ssa2, bool get_range)
+{
+ int_range_max tmp;
+ if (!m_oracle || TREE_CODE (ssa1) != SSA_NAME || TREE_CODE (ssa2) != SSA_NAME)
+ return VREL_NONE;
+
+ // Ensure ssa1 and ssa2 have both been evaluated.
+ if (get_range)
+ {
+ range_of_expr (tmp, ssa1, s);
+ range_of_expr (tmp, 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 defintions 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;
+ int_range_max tmp;
+ if (!m_oracle || TREE_CODE (ssa1) != SSA_NAME || TREE_CODE (ssa2) != SSA_NAME)
+ return VREL_NONE;
+
+ // 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)
+ {
+ range_on_edge (tmp, e, ssa1);
+ range_on_edge (tmp, e, ssa2);
+ }
+ return m_oracle->query_relation (bb, ssa1, ssa2);
+}