public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3245] Add method to query the sign of a NAN.
@ 2022-10-12  6:51 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2022-10-12  6:51 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:658788f3480e95f1dda0a143b60be89099e5d3c7

commit r13-3245-g658788f3480e95f1dda0a143b60be89099e5d3c7
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Oct 11 19:21:14 2022 +0200

    Add method to query the sign of a NAN.
    
    In writing some range-op entries I noticed we don't have a way to
    query the sign of the NAN in a range, unless the range only contains
    NAN, in which case you can just use frange::signbit_p.  This patch
    adds a method that returns TRUE if there exists the possiblity of a
    NAN and we know its sign.
    
    gcc/ChangeLog:
    
            * value-range.h (frange::nan_signbit_p): New.

Diff:
---
 gcc/value-range.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gcc/value-range.h b/gcc/value-range.h
index cb5e9d0522c..60b989b2b50 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -328,6 +328,7 @@ public:
   bool maybe_isnan (bool sign) const;
   bool maybe_isinf () const;
   bool signbit_p (bool &signbit) const;
+  bool nan_signbit_p (bool &signbit) const;
 private:
   void verify_range ();
   bool normalize_kind ();
@@ -1358,4 +1359,20 @@ frange::signbit_p (bool &signbit) const
   return false;
 }
 
+// If range has a NAN with a known sign, set it in SIGNBIT and return
+// TRUE.
+
+inline bool
+frange::nan_signbit_p (bool &signbit) const
+{
+  if (undefined_p ())
+    return false;
+
+  if (m_pos_nan == m_neg_nan)
+    return false;
+
+  signbit = m_neg_nan;
+  return true;
+}
+
 #endif // GCC_VALUE_RANGE_H

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

only message in thread, other threads:[~2022-10-12  6:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12  6:51 [gcc r13-3245] Add method to query the sign of a NAN 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).