]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add frange::maybe_isnan (bool sign).
authorAldy Hernandez <aldyh@redhat.com>
Mon, 10 Oct 2022 11:43:16 +0000 (13:43 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 10 Oct 2022 12:50:17 +0000 (14:50 +0200)
It is useful to know if there's the possiblity of a NAN with a given
sign.  This is to complement maybe_isnan(void) which returns TRUE for a
NAN of any sign.

A follow-up patch implementing ABS will make use of this.

gcc/ChangeLog:

* value-range.h (frange::maybe_isnan): New.

gcc/value-range.h

index 484f911bd9051bfdafffa089b6c03895fc0ed5a4..07a2067898c9efe6fe7ae8e163922556283bab10 100644 (file)
@@ -323,6 +323,7 @@ public:
   bool known_isnan () const;
   bool known_isinf () const;
   bool maybe_isnan () const;
+  bool maybe_isnan (bool sign) const;
   bool maybe_isinf () const;
   bool signbit_p (bool &signbit) const;
 private:
@@ -1295,6 +1296,18 @@ frange::maybe_isnan () const
   return m_pos_nan || m_neg_nan;
 }
 
+// Return TRUE if range is possibly a NAN with SIGN.
+
+inline bool
+frange::maybe_isnan (bool sign) const
+{
+  if (undefined_p ())
+    return false;
+  if (sign)
+    return m_neg_nan;
+  return m_pos_nan;
+}
+
 // Return TRUE if range is a +NAN or -NAN.
 
 inline bool