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] Add frange::maybe_isnan (bool sign).
Date: Mon, 10 Oct 2022 14:49:45 +0200 [thread overview]
Message-ID: <20221010124946.154152-4-aldyh@redhat.com> (raw)
In-Reply-To: <20221010124946.154152-1-aldyh@redhat.com>
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 | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 484f911bd90..07a2067898c 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -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
--
2.37.3
next prev parent reply other threads:[~2022-10-10 12:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 12:49 [COMMITTED] Return non-legacy ranges in range.h Aldy Hernandez
2022-10-10 12:49 ` [COMMITTED] x UNORD x should set NAN on the TRUE side (and !NAN on the FALSE side) Aldy Hernandez
2022-10-10 12:49 ` [COMMITTED] The true side of x != x should set NAN Aldy Hernandez
2022-10-10 12:49 ` Aldy Hernandez [this message]
2022-10-10 12:49 ` [COMMITTED] Make range-op-float entries public 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=20221010124946.154152-4-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).