]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Invoke range_of_stmt on ssa_names with no context.
authorAndrew MacLeod <amacleod@redhat.com>
Wed, 13 Mar 2024 18:13:28 +0000 (14:13 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 30 Apr 2024 21:19:57 +0000 (17:19 -0400)
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.

gcc/gimple-range.cc

index 4d3b1ce8588470751d2e4fae7d7a847f2d75b098..3966cfbd14cd1186a03e7c28d1c84719bde11ea0 100644 (file)
@@ -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))