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 method to query the sign of a NAN.
Date: Wed, 12 Oct 2022 08:50:49 +0200 [thread overview]
Message-ID: <20221012065050.412900-4-aldyh@redhat.com> (raw)
In-Reply-To: <20221012065050.412900-1-aldyh@redhat.com>
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.
---
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
--
2.37.3
next prev parent reply other threads:[~2022-10-12 6:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 6:50 [COMMITTED] Add default relation_kind to floating point range-op entries Aldy Hernandez
2022-10-12 6:50 ` [COMMITTED] Add an frange(type) constructor analogous to the irange version Aldy Hernandez
2022-10-12 6:50 ` [COMMITTED] Disable tree to bool conversion in frange::update_nan Aldy Hernandez
2022-10-12 6:50 ` Aldy Hernandez [this message]
2022-10-12 6:50 ` [COMMITTED] Add stubs for floating point range-op tests 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=20221012065050.412900-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).