public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-3411] Do not set NAN flags for VARYING ranges when !HONOR_NANS.
Date: Thu, 20 Oct 2022 14:24:30 +0000 (GMT)	[thread overview]
Message-ID: <20221020142430.5395E3850862@sourceware.org> (raw)

https://gcc.gnu.org/g:f4fda3eec408e1eb12cc966f55f0de396be71597

commit r13-3411-gf4fda3eec408e1eb12cc966f55f0de396be71597
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu Oct 20 08:55:36 2022 +0200

    Do not set NAN flags for VARYING ranges when !HONOR_NANS.
    
    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.

Diff:
---
 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

                 reply	other threads:[~2022-10-20 14:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221020142430.5395E3850862@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@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).