public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-126] Replace !irange::undefined_p checks with num_ranges > 0 for readability.
@ 2021-04-26 13:45 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-04-26 13:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:778032166d960d97541e652c59684d1187d0233c

commit r12-126-g778032166d960d97541e652c59684d1187d0233c
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sat Apr 17 14:24:15 2021 +0200

    Replace !irange::undefined_p checks with num_ranges > 0 for readability.
    
    A few of the undefined_p checks in the irange code are really checking if
    there are sub-ranges.  It just so happens that undefined_p is
    implemented with num_ranges > 0, so it was a shorthand used throughout.
    This shorthand was making the code unreadable.
    
    gcc/ChangeLog:
    
            * value-range.cc (irange::legacy_lower_bound): Replace
              !undefined_p check with num_ranges > 0.
            (irange::legacy_upper_bound): Same.
            * value-range.h (irange::type): Same.
            (irange::lower_bound): Same.
            (irange::upper_bound): Same.

Diff:
---
 gcc/value-range.cc | 4 ++--
 gcc/value-range.h  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index cd21f75909b..d46662397e7 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -441,7 +441,7 @@ irange::legacy_lower_bound (unsigned pair) const
       numeric_range.normalize_symbolics ();
       return numeric_range.legacy_lower_bound (pair);
     }
-  gcc_checking_assert (!undefined_p ());
+  gcc_checking_assert (m_num_ranges > 0);
   gcc_checking_assert (pair + 1 <= num_pairs ());
   if (m_kind == VR_ANTI_RANGE)
     {
@@ -468,7 +468,7 @@ irange::legacy_upper_bound (unsigned pair) const
       numeric_range.normalize_symbolics ();
       return numeric_range.legacy_upper_bound (pair);
     }
-  gcc_checking_assert (!undefined_p ());
+  gcc_checking_assert (m_num_ranges > 0);
   gcc_checking_assert (pair + 1 <= num_pairs ());
   if (m_kind == VR_ANTI_RANGE)
     {
diff --git a/gcc/value-range.h b/gcc/value-range.h
index bfc54a2473f..bb27e706207 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -224,7 +224,7 @@ irange::num_pairs () const
 inline tree
 irange::type () const
 {
-  gcc_checking_assert (!undefined_p ());
+  gcc_checking_assert (m_num_ranges > 0);
   return TREE_TYPE (m_base[0]);
 }
 
@@ -501,7 +501,7 @@ irange::lower_bound (unsigned pair) const
 {
   if (legacy_mode_p ())
     return legacy_lower_bound (pair);
-  gcc_checking_assert (!undefined_p ());
+  gcc_checking_assert (m_num_ranges > 0);
   gcc_checking_assert (pair + 1 <= num_pairs ());
   return wi::to_wide (tree_lower_bound (pair));
 }
@@ -514,7 +514,7 @@ irange::upper_bound (unsigned pair) const
 {
   if (legacy_mode_p ())
     return legacy_upper_bound (pair);
-  gcc_checking_assert (!undefined_p ());
+  gcc_checking_assert (m_num_ranges > 0);
   gcc_checking_assert (pair + 1 <= num_pairs ());
   return wi::to_wide (tree_upper_bound (pair));
 }


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

only message in thread, other threads:[~2021-04-26 13:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 13:45 [gcc r12-126] Replace !irange::undefined_p checks with num_ranges > 0 for readability Aldy Hernandez

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