diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2023-05-23 15:41:03 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2023-05-24 08:39:58 -0400 |
commit | 257c2be7ff8dfdc610202a1e1f5a8a668b939bdb (patch) | |
tree | c69a7f0a8973a3993185cccc8d27ef28b85f9a7d | |
parent | cfd6569e9c41181231a8427235d0c0a7ad9262e4 (diff) | |
download | gcc-257c2be7ff8dfdc610202a1e1f5a8a668b939bdb.zip gcc-257c2be7ff8dfdc610202a1e1f5a8a668b939bdb.tar.gz gcc-257c2be7ff8dfdc610202a1e1f5a8a668b939bdb.tar.bz2 |
Only update global value if it changes.
Do not update and propagate a global value if it hasn't changed.
PR tree-optimization/109695
* gimple-range-cache.cc (ranger_cache::get_global_range): Add
changed param.
* gimple-range-cache.h (ranger_cache::get_global_range): Ditto.
* gimple-range.cc (gimple_ranger::range_of_stmt): Pass changed
flag to set_global_range.
(gimple_ranger::prefill_stmt_dependencies): Ditto.
-rw-r--r-- | gcc/gimple-range-cache.cc | 10 | ||||
-rw-r--r-- | gcc/gimple-range-cache.h | 2 | ||||
-rw-r--r-- | gcc/gimple-range.cc | 8 |
3 files changed, 14 insertions, 6 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index db7ee8e..e069241 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -992,10 +992,18 @@ ranger_cache::get_global_range (vrange &r, tree name, bool ¤t_p) // Set the global range of NAME to R and give it a timestamp. void -ranger_cache::set_global_range (tree name, const vrange &r) +ranger_cache::set_global_range (tree name, const vrange &r, bool changed) { // Setting a range always clears the always_current flag. m_temporal->set_always_current (name, false); + if (!changed) + { + // If there are dependencies, make sure this is not out of date. + if (!m_temporal->current_p (name, m_gori.depend1 (name), + m_gori.depend2 (name))) + m_temporal->set_timestamp (name); + return; + } if (m_globals.set_range (name, r)) { // If there was already a range set, propagate the new value. diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index 946fbc5..871255a 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -117,7 +117,7 @@ public: bool get_global_range (vrange &r, tree name) const; bool get_global_range (vrange &r, tree name, bool ¤t_p); - void set_global_range (tree name, const vrange &r); + void set_global_range (tree name, const vrange &r, bool changed = true); void propagate_updated_value (tree name, basic_block bb); diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index a275c09..4fae3f9 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -320,8 +320,8 @@ gimple_ranger::range_of_stmt (vrange &r, gimple *s, tree name) // Combine the new value with the old value. This is required because // the way value propagation works, when the IL changes on the fly we // can sometimes get different results. See PR 97741. - r.intersect (tmp); - m_cache.set_global_range (name, r); + bool changed = r.intersect (tmp); + m_cache.set_global_range (name, r, changed); res = true; } @@ -393,8 +393,8 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa) // Make sure we don't lose any current global info. Value_Range tmp (TREE_TYPE (name)); m_cache.get_global_range (tmp, name); - r.intersect (tmp); - m_cache.set_global_range (name, r); + bool changed = tmp.intersect (r); + m_cache.set_global_range (name, tmp, changed); } continue; } |