public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4866] Provide some context to folding via ranger.
@ 2021-11-03 14:38 Andrew Macleod
0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2021-11-03 14:38 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:fc4076752067fb400b43adbd629081df658da246
commit r12-4866-gfc4076752067fb400b43adbd629081df658da246
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Mon Nov 1 13:32:11 2021 -0400
Provide some context to folding via ranger.
Provide an internal mechanism to supply context to range_of_expr for calls
to ::fold_stmt.
* gimple-range.cc (gimple_ranger::gimple_ranger): Initialize current_bb.
(gimple_ranger::range_of_expr): Pick up range_on_entry when there is
no explcit context and current_bb is set.
(gimple_ranger::fold_stmt): New.
* gimple-range.h (current_bb, fold_stmt): New.
* tree-vrp.c (rvrp_folder::fold_stmt): Call ranger's fold_stmt.
Diff:
---
gcc/gimple-range.cc | 28 +++++++++++++++++++++++++++-
gcc/gimple-range.h | 2 ++
gcc/tree-vrp.c | 2 +-
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 2c9715a6f2c..e1177b1c5e8 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -34,11 +34,13 @@ along with GCC; see the file COPYING3. If not see
#include "cfgloop.h"
#include "tree-scalar-evolution.h"
#include "gimple-range.h"
+#include "gimple-fold.h"
gimple_ranger::gimple_ranger () :
non_executable_edge_flag (cfun),
m_cache (non_executable_edge_flag),
- tracer ("")
+ tracer (""),
+ current_bb (NULL)
{
// If the cache has a relation oracle, use it.
m_oracle = m_cache.oracle ();
@@ -82,8 +84,19 @@ gimple_ranger::range_of_expr (irange &r, tree expr, gimple *stmt)
// If there is no statement, just get the global value.
if (!stmt)
{
+ int_range_max tmp;
if (!m_cache.get_global_range (r, expr))
r = gimple_range_global (expr);
+ // Pick up implied context information from the on-entry cache
+ // if current_bb is set.
+ if (current_bb && m_cache.block_range (tmp, current_bb, expr))
+ {
+ r.intersect (tmp);
+ char str[80];
+ sprintf (str, "picked up range from bb %d\n",current_bb->index);
+ if (idx)
+ tracer.print (idx, str);
+ }
}
// For a debug stmt, pick the best value currently available, do not
// trigger new value calculations. PR 100781.
@@ -295,6 +308,19 @@ gimple_ranger::range_of_stmt (irange &r, gimple *s, tree name)
return res;
}
+// This routine will invoke the gimple fold_stmt routine, providing context to
+// range_of_expr calls via an private interal API.
+
+bool
+gimple_ranger::fold_stmt (gimple_stmt_iterator *gsi, tree (*valueize) (tree))
+{
+ gimple *stmt = gsi_stmt (*gsi);
+ current_bb = gimple_bb (stmt);
+ bool ret = ::fold_stmt (gsi, valueize);
+ current_bb = NULL;
+ return ret;
+}
+
// This routine will export whatever global ranges are known to GCC
// SSA_RANGE_NAME_INFO and SSA_NAME_PTR_INFO fields.
diff --git a/gcc/gimple-range.h b/gcc/gimple-range.h
index 0713af40fcd..615496ec9b8 100644
--- a/gcc/gimple-range.h
+++ b/gcc/gimple-range.h
@@ -58,10 +58,12 @@ public:
void debug ();
void dump_bb (FILE *f, basic_block bb);
auto_edge_flag non_executable_edge_flag;
+ bool fold_stmt (gimple_stmt_iterator *gsi, tree (*) (tree));
protected:
bool fold_range_internal (irange &r, gimple *s, tree name);
ranger_cache m_cache;
range_tracer tracer;
+ basic_block current_bb;
};
/* Create a new ranger instance and associate it with a function.
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index dc3e250537a..5380508a9ec 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4323,7 +4323,7 @@ public:
{
if (m_simplifier.simplify (gsi))
return true;
- return ::fold_stmt (gsi, follow_single_use_edges);
+ return m_ranger->fold_stmt (gsi, follow_single_use_edges);
}
private:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-03 14:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 14:38 [gcc r12-4866] Provide some context to folding via ranger 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).