public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-370] Remove irange::tree_{lower,upper}_bound.
Date: Mon,  1 May 2023 06:33:48 +0000 (GMT)	[thread overview]
Message-ID: <20230501063348.3A31F3853838@sourceware.org> (raw)

https://gcc.gnu.org/g:6b73cbb04d486b96052236a7649175988e3cbf53

commit r14-370-g6b73cbb04d486b96052236a7649175988e3cbf53
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Jan 24 21:05:24 2023 +0100

    Remove irange::tree_{lower,upper}_bound.
    
    gcc/ChangeLog:
    
            * value-range.cc (irange::irange_set_anti_range): Remove uses of
            tree_lower_bound and tree_upper_bound.
            (irange::verify_range): Same.
            (irange::operator==): Same.
            (irange::singleton_p): Same.
            * value-range.h (irange::tree_lower_bound): Delete.
            (irange::tree_upper_bound): Delete.
            (irange::lower_bound): Delete.
            (irange::upper_bound): Delete.
            (irange::zero_p): Remove uses of tree_lower_bound and
            tree_upper_bound.

Diff:
---
 gcc/value-range.cc | 36 ++++++++++++++++++------------------
 gcc/value-range.h  | 39 ++++-----------------------------------
 2 files changed, 22 insertions(+), 53 deletions(-)

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index ee43efa1ab5..a0e49df28f3 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -1010,7 +1010,7 @@ irange::irange_set_anti_range (tree min, tree max)
     {
       wide_int lim1 = wi::sub (w_min, 1, sign, &ovf);
       gcc_checking_assert (ovf != wi::OVF_OVERFLOW);
-      m_base[0] = type_range.tree_lower_bound (0);
+      m_base[0] = wide_int_to_tree (type, type_range.lower_bound (0));
       m_base[1] = wide_int_to_tree (type, lim1);
       m_num_ranges = 1;
     }
@@ -1025,7 +1025,8 @@ irange::irange_set_anti_range (tree min, tree max)
       wide_int lim2 = wi::add (w_max, 1, sign, &ovf);
       gcc_checking_assert (ovf != wi::OVF_OVERFLOW);
       m_base[m_num_ranges * 2] = wide_int_to_tree (type, lim2);
-      m_base[m_num_ranges * 2 + 1] = type_range.tree_upper_bound (0);
+      m_base[m_num_ranges * 2 + 1]
+	= wide_int_to_tree (type, type_range.upper_bound (0));
       ++m_num_ranges;
     }
 
@@ -1104,9 +1105,9 @@ irange::verify_range ()
   gcc_checking_assert (!varying_compatible_p ());
   for (unsigned i = 0; i < m_num_ranges; ++i)
     {
-      tree lb = tree_lower_bound (i);
-      tree ub = tree_upper_bound (i);
-      int c = compare_values (lb, ub);
+      wide_int lb = lower_bound (i);
+      wide_int ub = upper_bound (i);
+      int c = wi::cmp (lb, ub, TYPE_SIGN (type ()));
       gcc_checking_assert (c == 0 || c == -1);
     }
 }
@@ -1120,20 +1121,20 @@ irange::operator== (const irange &other) const
   if (m_num_ranges == 0)
     return true;
 
+  signop sign1 = TYPE_SIGN (type ());
+  signop sign2 = TYPE_SIGN (other.type ());
+
   for (unsigned i = 0; i < m_num_ranges; ++i)
     {
-      tree lb = tree_lower_bound (i);
-      tree ub = tree_upper_bound (i);
-      tree lb_other = other.tree_lower_bound (i);
-      tree ub_other = other.tree_upper_bound (i);
-      if (!operand_equal_p (lb, lb_other, 0)
-	  || !operand_equal_p (ub, ub_other, 0))
+      widest_int lb = widest_int::from (lower_bound (i), sign1);
+      widest_int ub = widest_int::from (upper_bound (i), sign1);
+      widest_int lb_other = widest_int::from (other.lower_bound (i), sign2);
+      widest_int ub_other = widest_int::from (other.upper_bound (i), sign2);
+      if (lb != lb_other || ub != ub_other)
 	return false;
     }
-  widest_int nz1 = widest_int::from (get_nonzero_bits (),
-				     TYPE_SIGN (type ()));
-  widest_int nz2 = widest_int::from (other.get_nonzero_bits (),
-				     TYPE_SIGN (other.type ()));
+  widest_int nz1 = widest_int::from (get_nonzero_bits (), sign1);
+  widest_int nz2 = widest_int::from (other.get_nonzero_bits (), sign2);
   return nz1 == nz2;
 }
 
@@ -1144,11 +1145,10 @@ irange::operator== (const irange &other) const
 bool
 irange::singleton_p (tree *result) const
 {
-  if (num_pairs () == 1 && (wi::to_wide (tree_lower_bound ())
-			    == wi::to_wide (tree_upper_bound ())))
+  if (num_pairs () == 1 && lower_bound () == upper_bound ())
     {
       if (result)
-	*result = tree_lower_bound ();
+	*result = wide_int_to_tree (type (), lower_bound ());
       return true;
     }
   return false;
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 68f380a2dbb..10c44c5c062 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -168,10 +168,6 @@ public:
 
 protected:
   irange (tree *, unsigned);
-  // potential promotion to public?
-  tree tree_lower_bound (unsigned = 0) const;
-  tree tree_upper_bound (unsigned) const;
-  tree tree_upper_bound () const;
 
    // In-place operators.
   bool irange_union (const irange &);
@@ -654,33 +650,6 @@ irange::type () const
   return TREE_TYPE (m_base[0]);
 }
 
-// Return the lower bound of a sub-range expressed as a tree.  PAIR is
-// the sub-range in question.
-
-inline tree
-irange::tree_lower_bound (unsigned pair) const
-{
-  return m_base[pair * 2];
-}
-
-// Return the upper bound of a sub-range expressed as a tree.  PAIR is
-// the sub-range in question.
-
-inline tree
-irange::tree_upper_bound (unsigned pair) const
-{
-  return m_base[pair * 2 + 1];
-}
-
-// Return the highest bound of a range expressed as a tree.
-
-inline tree
-irange::tree_upper_bound () const
-{
-  gcc_checking_assert (m_num_ranges);
-  return tree_upper_bound (m_num_ranges - 1);
-}
-
 inline bool
 irange::varying_compatible_p () const
 {
@@ -730,8 +699,8 @@ inline bool
 irange::zero_p () const
 {
   return (m_kind == VR_RANGE && m_num_ranges == 1
-	  && integer_zerop (tree_lower_bound (0))
-	  && integer_zerop (tree_upper_bound (0)));
+	  && lower_bound (0) == 0
+	  && upper_bound (0) == 0);
 }
 
 inline bool
@@ -910,7 +879,7 @@ irange::lower_bound (unsigned pair) const
 {
   gcc_checking_assert (m_num_ranges > 0);
   gcc_checking_assert (pair + 1 <= num_pairs ());
-  return wi::to_wide (tree_lower_bound (pair));
+  return wi::to_wide (m_base[pair * 2]);
 }
 
 // Return the upper bound of a sub-range.  PAIR is the sub-range in
@@ -921,7 +890,7 @@ irange::upper_bound (unsigned pair) const
 {
   gcc_checking_assert (m_num_ranges > 0);
   gcc_checking_assert (pair + 1 <= num_pairs ());
-  return wi::to_wide (tree_upper_bound (pair));
+  return wi::to_wide (m_base[pair * 2 + 1]);
 }
 
 // Return the highest bound of a range.

                 reply	other threads:[~2023-05-01  6:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230501063348.3A31F3853838@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).