]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use TYPE_MIN/MAX_VALUE in set_varying when possible.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 28 Sep 2021 17:11:22 +0000 (13:11 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 6 Oct 2021 13:11:50 +0000 (09:11 -0400)
We currently create new trees every time... which is very wasteful and time
consuming. Instead, just use the TYPE_MIN/MAX_VALUE.

* value-range.h (irange::set_varying): Use TYPE_MIN_VALUE and
TYPE_MAX_VALUE instead of creating new trees when possible.

gcc/value-range.h

index a8adc50b98ef836d47b4bbc46547529cc9bf3caa..39e8f3bcdee845bf95dfd8f62ed17b261689e1af 100644 (file)
@@ -476,10 +476,21 @@ irange::set_varying (tree type)
 
   if (INTEGRAL_TYPE_P (type))
     {
+      // Strict enum's require varying to be not TYPE_MIN/MAX, but rather
+      // min_value and max_value.
       wide_int min = wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type));
       wide_int max = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
-      m_base[0] = wide_int_to_tree (type, min);
-      m_base[1] = wide_int_to_tree (type, max);
+      if (wi::eq_p (max, wi::to_wide (TYPE_MAX_VALUE (type)))
+         && wi::eq_p (min, wi::to_wide (TYPE_MIN_VALUE (type))))
+       {
+         m_base[0] = TYPE_MIN_VALUE (type);
+         m_base[1] = TYPE_MAX_VALUE (type);
+       }
+      else
+       {
+         m_base[0] = wide_int_to_tree (type, min);
+         m_base[1] = wide_int_to_tree (type, max);
+       }
     }
   else if (POINTER_TYPE_P (type))
     {