aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2024-03-13 14:13:28 -0400
committerAndrew MacLeod <amacleod@redhat.com>2024-04-30 17:19:57 -0400
commit0ade358cd72ffa591dd2f1404765b379bbf709d4 (patch)
tree99af6e7dc12e97ba982807488b29ab58015bdf50
parente8ae56a7dc46e39a48017bb5159e4dc672ec7fad (diff)
Invoke range_of_stmt on ssa_names with no context.
Evalaute ssa-names when range_of_expr is called with no context statement by calling range_of_stmt to get an initial value. * gimple-range.cc (gimple_ranger::range_of_expr): Call range_of_stmt when there is no context stmt.
-rw-r--r--gcc/gimple-range.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 4d3b1ce8588..3966cfbd14c 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -102,7 +102,15 @@ gimple_ranger::range_of_expr (vrange &r, tree expr, gimple *stmt)
if (!stmt)
{
Value_Range tmp (TREE_TYPE (expr));
- m_cache.get_global_range (r, expr);
+ // If there is no global range for EXPR yet, try to evaluate it.
+ // This call sets R to a global range regardless.
+ if (!m_cache.get_global_range (r, expr))
+ {
+ gimple *s = SSA_NAME_DEF_STMT (expr);
+ // Calculate a range for S if it is safe to do so.
+ if (s && gimple_bb (s) && gimple_get_lhs (s) == expr)
+ return range_of_stmt (r, s);
+ }
// Pick up implied context information from the on-entry cache
// if current_bb is set. Do not attempt any new calculations.
if (current_bb && m_cache.block_range (tmp, current_bb, expr, false))