aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2020-06-09 12:32:00 +0200
committerAldy Hernandez <aldyh@redhat.com>2020-06-09 20:18:39 +0200
commit2f28c16f0d0be8bbf75cee0363bdbe1718c2c538 (patch)
tree483a9b1cfe07cb37c6ec37118407cb6c58588a5e /gcc
parentdf663310eec78e530cb3360434791352139f496f (diff)
downloadgcc-2f28c16f0d0be8bbf75cee0363bdbe1718c2c538.zip
gcc-2f28c16f0d0be8bbf75cee0363bdbe1718c2c538.tar.gz
gcc-2f28c16f0d0be8bbf75cee0363bdbe1718c2c538.tar.bz2
Implement loop_ranger::range_of_stmt to use SCEV when evaluating PHI's.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-ranger.cc22
-rw-r--r--gcc/gimple-ranger.h3
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr21458.c6
4 files changed, 33 insertions, 2 deletions
diff --git a/gcc/gimple-ranger.cc b/gcc/gimple-ranger.cc
index edc996f..22853a9 100644
--- a/gcc/gimple-ranger.cc
+++ b/gcc/gimple-ranger.cc
@@ -791,6 +791,28 @@ loop_ranger::range_of_phi (irange &r, gphi *phi)
return range_with_loop_info (r, PHI_RESULT (phi));
}
+bool
+loop_ranger::range_of_stmt (irange &r, gimple *stmt, tree name)
+{
+ // If there is no global range for a PHI, start the party with
+ // whatever information SCEV may have.
+ if (gphi *phi = dyn_cast<gphi *> (stmt))
+ {
+ tree phi_result = PHI_RESULT (phi);
+ if (!POINTER_TYPE_P (TREE_TYPE (phi_result))
+ && !m_globals.get_global_range (r, phi_result)
+ && range_with_loop_info (r, phi_result))
+ {
+ value_range loop_range;
+ get_range_info (phi_result, loop_range);
+ r.intersect (loop_range);
+ if (!r.varying_p ())
+ set_range_info (phi_result, r);
+ }
+ }
+ return super::range_of_stmt (r, stmt, name);
+}
+
void
loop_ranger::range_on_edge (irange &r, edge e, tree name)
{
diff --git a/gcc/gimple-ranger.h b/gcc/gimple-ranger.h
index f3f5eb6..f9b7cff 100644
--- a/gcc/gimple-ranger.h
+++ b/gcc/gimple-ranger.h
@@ -57,6 +57,7 @@ public:
protected:
virtual void range_of_ssa_name (irange &r, tree name, gimple *s = NULL);
bool range_from_import (irange &r, tree name, irange &import_range);
+ ssa_global_cache m_globals;
private:
typedef gimple_ranger super;
bool non_null_deref_p (tree name, basic_block bb);
@@ -68,7 +69,6 @@ private:
void fill_block_cache (tree name, basic_block bb, basic_block def_bb);
void iterative_cache_update (tree name);
- ssa_global_cache m_globals;
block_range_cache m_on_entry;
non_null_ref m_non_null;
vec<basic_block> m_workback;
@@ -85,6 +85,7 @@ public:
~loop_ranger ();
virtual void range_on_edge (irange &r, edge e, tree name);
virtual bool range_of_phi (irange &r, gphi *phi);
+ virtual bool range_of_stmt (irange &r, gimple *stmt, tree name);
private:
typedef global_ranger super;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
index 2aee42f..cccf9e7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
@@ -1,6 +1,10 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-evrp-details" } */
+/* range_of_stmt will call SCEV to set global ranges for the PHI
+ results, and alter the results here. */
+/* { dg-additional-options "-fdisable-tree-rvrp1 -fdisable-tree-rvrp2" } */
+
extern void g (void);
extern void bar (int);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21458.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21458.c
index 7b0de64..f81b62a 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21458.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21458.c
@@ -1,5 +1,9 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1 -fno-rvrp-changes" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1" } */
+
+/* range_of_stmt will call SCEV to set global ranges for the PHI
+ results, and alter the results here. */
+/* { dg-additional-options "-fdisable-tree-rvrp1 -fdisable-tree-rvrp2" } */
extern void g (void);
extern void bar (int);