]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Choose better initial values for ranger.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 23 May 2023 19:11:44 +0000 (15:11 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 24 May 2023 12:39:58 +0000 (08:39 -0400)
Instead of defaulting to VARYING, fold the stmt using just global ranges.

PR tree-optimization/109695
* gimple-range-cache.cc (ranger_cache::get_global_range): Call
fold_range with global query to choose an initial value.

gcc/gimple-range-cache.cc

index 07c69ef858a67d103b31065479e0df38a156b6e5..8ddfd9426c09c771ea41894eb6125f17baf9af2f 100644 (file)
@@ -951,7 +951,22 @@ ranger_cache::get_global_range (vrange &r, tree name, bool &current_p)
                || m_temporal->current_p (name, m_gori.depend1 (name),
                                          m_gori.depend2 (name));
   else
-    m_globals.set_range (name, r);
+    {
+      // If no global value has been set and value is VARYING, fold the stmt
+      // using just global ranges to get a better initial value.
+      // After inlining we tend to decide some things are constant, so
+      // so not do this evaluation after inlining.
+      if (r.varying_p () && !cfun->after_inlining)
+       {
+         gimple *s = SSA_NAME_DEF_STMT (name);
+         if (gimple_get_lhs (s) == name)
+           {
+             if (!fold_range (r, s, get_global_range_query ()))
+               gimple_range_global (r, name);
+           }
+       }
+      m_globals.set_range (name, r);
+    }
 
   // If the existing value was not current, mark it as always current.
   if (!current_p)