public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aldyh/heads/ranger-relational)] Add relation_oracle to query_range
@ 2021-04-16 13:25 Andrew Macleod
0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2021-04-16 13:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a79cc1008f54bb1d1379ec71fe17ca54467cc920
commit a79cc1008f54bb1d1379ec71fe17ca54467cc920
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Thu Apr 15 13:56:31 2021 -0400
Add relation_oracle to query_range
Diff:
---
gcc/value-query.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
gcc/value-query.h | 10 +++++++++-
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index 4bb0897c446..d24eb398c14 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -168,6 +168,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 ()
@@ -175,3 +176,52 @@ range_query::~range_query ()
equiv_alloc->release ();
delete equiv_alloc;
}
+
+
+// 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 haven 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 haven 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;
+
+ // Choose the block. Destination is only valid if it's single pred.
+ // otherwise its 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);
+}
diff --git a/gcc/value-query.h b/gcc/value-query.h
index e2cbc6852b0..54a5ed92980 100644
--- a/gcc/value-query.h
+++ b/gcc/value-query.h
@@ -22,6 +22,8 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_QUERY_H
#define GCC_QUERY_H
+#include "value-relation.h"
+
// The value_query class is used by optimization passes that require
// valueizing SSA names in terms of a tree value, but have no neeed
// for ranges.
@@ -91,15 +93,21 @@ public:
virtual bool range_on_edge (irange &r, edge, tree name);
virtual bool range_of_stmt (irange &r, gimple *, tree name = NULL);
+ relation_kind query_relation (gimple *s, tree ssa1, tree ssa2,
+ bool get_range = true);
+ relation_kind query_relation (edge e, tree ssa1, tree ssa2,
+ bool get_range = true);
+ inline relation_oracle *oracle () const { return m_oracle; }
+
// DEPRECATED: This method is used from vr-values. The plan is to
// rewrite all uses of it to the above API.
virtual const class value_range_equiv *get_value_range (const_tree,
gimple * = NULL);
-
protected:
class value_range_equiv *allocate_value_range_equiv ();
void free_value_range_equiv (class value_range_equiv *);
+ class relation_oracle *m_oracle;
private:
class equiv_allocator *equiv_alloc;
};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-16 13:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 13:25 [gcc(refs/users/aldyh/heads/ranger-relational)] Add relation_oracle to query_range 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).