public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: GCC patches <gcc-patches@gcc.gnu.org>
Cc: Andrew MacLeod <amacleod@redhat.com>, Aldy Hernandez <aldyh@redhat.com>
Subject: [COMMITTED] Remove irange::tree_{lower,upper}_bound.
Date: Mon,  1 May 2023 08:28:57 +0200	[thread overview]
Message-ID: <20230501062906.564803-3-aldyh@redhat.com> (raw)
In-Reply-To: <20230501062906.564803-1-aldyh@redhat.com>

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.
---
 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.
-- 
2.40.0


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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01  6:28 [COMMITTED] vrange_storage overhaul Aldy Hernandez
2023-05-01  6:28 ` [COMMITTED] Remove irange::{min,max,kind} Aldy Hernandez
2023-05-01  6:28 ` Aldy Hernandez [this message]
2023-05-01  6:28 ` [COMMITTED] Various cleanups in vr-values.cc towards ranger API Aldy Hernandez
2023-05-01  6:28 ` [COMMITTED] Convert get_legacy_range in bounds_of_var_in_loop to irange API Aldy Hernandez
2023-05-01  6:29 ` [COMMITTED] Merge irange::union/intersect into irange_union/intersect Aldy Hernandez
2023-05-01  6:29 ` [COMMITTED] Conversion to irange wide_int API Aldy Hernandez
2023-05-01  6:29 ` [COMMITTED] Replace vrp_val* with wide_ints Aldy Hernandez
2023-05-01  6:29 ` [COMMITTED] Rewrite bounds_of_var_in_loop() to use ranges Aldy Hernandez
2023-05-01  6:29 ` [COMMITTED] Convert internal representation of irange to wide_ints Aldy Hernandez
2023-05-01  6:29 ` [COMMITTED] Cleanup irange::set Aldy Hernandez
2023-05-01  6:29 ` [COMMITTED] Inline irange::set_nonzero Aldy Hernandez

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=20230501062906.564803-3-aldyh@redhat.com \
    --to=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@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).