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.
// 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.
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);
// 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;
}
// 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;
}