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 r14-174] Handle NANs in frange::operator== [PR109593]
Date: Sun, 23 Apr 2023 09:04:17 +0000 (GMT)	[thread overview]
Message-ID: <20230423090417.8CC6A3858C50@sourceware.org> (raw)

https://gcc.gnu.org/g:5830953a446959c5d8d9b569ffcd3e3bb16a06dc

commit r14-174-g5830953a446959c5d8d9b569ffcd3e3bb16a06dc
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sun Apr 23 08:04:55 2023 +0200

    Handle NANs in frange::operator== [PR109593]
    
    This patch...
            commit 10e481b154c5fc63e6ce4b449ce86cecb87a6015
            Return true from operator== for two identical ranges containing NAN.
    
    removed the check for NANs, which caused us to read from m_min and
    m_max which are undefined for NANs.
    
    gcc/ChangeLog:
    
            PR tree-optimization/109593
            * value-range.cc (frange::operator==): Handle NANs.

Diff:
---
 gcc/value-range.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 17f4e1b9f59..97162413727 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -682,6 +682,16 @@ frange::operator== (const frange &src) const
       if (varying_p ())
 	return types_compatible_p (m_type, src.m_type);
 
+      bool nan1 = known_isnan ();
+      bool nan2 = src.known_isnan ();
+      if (nan1 || nan2)
+	{
+	  if (nan1 && nan2)
+	    return (m_pos_nan == src.m_pos_nan
+		    && m_neg_nan == src.m_neg_nan);
+	  return false;
+	}
+
       return (real_identical (&m_min, &src.m_min)
 	      && real_identical (&m_max, &src.m_max)
 	      && m_pos_nan == src.m_pos_nan

                 reply	other threads:[~2023-04-23  9:04 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=20230423090417.8CC6A3858C50@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).