public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
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] x UNORD x should set NAN on the TRUE side (and !NAN on the FALSE side).
Date: Mon, 10 Oct 2022 14:49:43 +0200	[thread overview]
Message-ID: <20221010124946.154152-2-aldyh@redhat.com> (raw)
In-Reply-To: <20221010124946.154152-1-aldyh@redhat.com>

gcc/ChangeLog:

	* range-op-float.cc (foperator_unordered::op1_range): Set NAN when
	operands are equal and result is TRUE.
---
 gcc/range-op-float.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 68578aa6fe7..91833d3f855 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -1026,23 +1026,27 @@ bool
 foperator_unordered::op1_range (frange &r, tree type,
 				const irange &lhs,
 				const frange &op2,
-				relation_kind) const
+				relation_kind rel) const
 {
   switch (get_bool_state (r, lhs, type))
     {
     case BRS_TRUE:
+      if (rel == VREL_EQ)
+	r.set_nan (type);
       // Since at least one operand must be NAN, if one of them is
       // not, the other must be.
-      if (!op2.maybe_isnan ())
+      else if (!op2.maybe_isnan ())
 	r.set_nan (type);
       else
 	r.set_varying (type);
       break;
 
     case BRS_FALSE:
+      if (rel == VREL_EQ)
+	r.clear_nan ();
       // A false UNORDERED means both operands are !NAN, so it's
       // impossible for op2 to be a NAN.
-      if (op2.known_isnan ())
+      else if (op2.known_isnan ())
 	r.set_undefined ();
       else
 	{
-- 
2.37.3


  reply	other threads:[~2022-10-10 12:49 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 ` Aldy Hernandez [this message]
2022-10-10 12:49 ` [COMMITTED] The true side of x != x should set NAN Aldy Hernandez
2022-10-10 12:49 ` [COMMITTED] Add frange::maybe_isnan (bool sign) Aldy Hernandez
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-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).