diff mbox series

[COMMITTED] x UNORD x should set NAN on the TRUE side (and !NAN on the FALSE side).

Message ID 20221010124946.154152-2-aldyh@redhat.com
State New
Headers show
Series [COMMITTED] x UNORD x should set NAN on the TRUE side (and !NAN on the FALSE side). | expand

Commit Message

Aldy Hernandez Oct. 10, 2022, 12:49 p.m. UTC
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 mbox series

Patch

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
 	{