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] Do not set NAN flags for VARYING ranges when !HONOR_NANS.
Date: Thu, 20 Oct 2022 16:13:36 +0200 [thread overview]
Message-ID: <20221020141336.228799-2-aldyh@redhat.com> (raw)
In-Reply-To: <20221020141336.228799-1-aldyh@redhat.com>
Since NANs can't appear in ranges for !HONOR_NANS, there's no reason
to set them in a VARYING range.
gcc/ChangeLog:
* value-range.h (frange::set_varying): Do not set NAN flags for
!HONOR_NANS.
* value-range.cc (frange::normalize_kind): Adjust for no NAN when
!HONOR_NANS.
(frange::verify_range): Same.
* range-op-float.cc (maybe_isnan): Remove flag_finite_math_only check.
---
gcc/range-op-float.cc | 3 ---
gcc/value-range.cc | 11 ++++++++---
gcc/value-range.h | 12 ++++++++++--
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 2a4a99ba467..a9e74c86877 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -171,9 +171,6 @@ range_operator_float::op1_op2_relation (const frange &lhs ATTRIBUTE_UNUSED) cons
static inline bool
maybe_isnan (const frange &op1, const frange &op2)
{
- if (flag_finite_math_only)
- return false;
-
return op1.maybe_isnan () || op2.maybe_isnan ();
}
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 511cd0ad767..bcda4987307 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -388,7 +388,7 @@ frange::normalize_kind ()
&& frange_val_is_min (m_min, m_type)
&& frange_val_is_max (m_max, m_type))
{
- if (m_pos_nan && m_neg_nan)
+ if (!HONOR_NANS (m_type) || (m_pos_nan && m_neg_nan))
{
set_varying (m_type);
return true;
@@ -396,7 +396,7 @@ frange::normalize_kind ()
}
else if (m_kind == VR_VARYING)
{
- if (!m_pos_nan || !m_neg_nan)
+ if (HONOR_NANS (m_type) && (!m_pos_nan || !m_neg_nan))
{
m_kind = VR_RANGE;
m_min = frange_val_min (m_type);
@@ -712,14 +712,19 @@ frange::supports_type_p (const_tree type) const
void
frange::verify_range ()
{
+ if (flag_finite_math_only)
+ gcc_checking_assert (!maybe_isnan ());
switch (m_kind)
{
case VR_UNDEFINED:
gcc_checking_assert (!m_type);
return;
case VR_VARYING:
+ if (flag_finite_math_only)
+ gcc_checking_assert (!m_pos_nan && !m_neg_nan);
+ else
+ gcc_checking_assert (m_pos_nan && m_neg_nan);
gcc_checking_assert (m_type);
- gcc_checking_assert (m_pos_nan && m_neg_nan);
gcc_checking_assert (frange_val_is_min (m_min, m_type));
gcc_checking_assert (frange_val_is_max (m_max, m_type));
return;
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 60b989b2b50..b48542a68aa 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -1103,8 +1103,16 @@ frange::set_varying (tree type)
m_type = type;
m_min = frange_val_min (type);
m_max = frange_val_max (type);
- m_pos_nan = true;
- m_neg_nan = true;
+ if (HONOR_NANS (m_type))
+ {
+ m_pos_nan = true;
+ m_neg_nan = true;
+ }
+ else
+ {
+ m_pos_nan = false;
+ m_neg_nan = false;
+ }
}
inline void
--
2.37.3
next prev parent reply other threads:[~2022-10-20 14:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 14:13 [COMMITTED] Replace finite_operands_p with maybe_isnan Aldy Hernandez
2022-10-20 14:13 ` Aldy Hernandez [this message]
2022-10-20 18:56 ` Mikael Morin
2022-10-20 18:58 ` Mikael Morin
2022-10-20 19:17 ` 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=20221020141336.228799-2-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).