public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4210] Use TYPE_MIN/MAX_VALUE in set_varying when possible.
@ 2021-10-06 14:52 Andrew Macleod
  0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2021-10-06 14:52 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e828f4b5898896240b2ae5d5030c539aff28ea24

commit r12-4210-ge828f4b5898896240b2ae5d5030c539aff28ea24
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Tue Sep 28 13:11:22 2021 -0400

    Use TYPE_MIN/MAX_VALUE in set_varying when possible.
    
    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.

Diff:
---
 gcc/value-range.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/value-range.h b/gcc/value-range.h
index a8adc50b98e..39e8f3bcdee 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -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))
     {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-06 14:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 14:52 [gcc r12-4210] Use TYPE_MIN/MAX_VALUE in set_varying when possible Andrew Macleod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).