]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x UNORD x should set NAN on the TRUE side (and !NAN on the FALSE side).
authorAldy Hernandez <aldyh@redhat.com>
Mon, 10 Oct 2022 09:01:48 +0000 (11:01 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 10 Oct 2022 12:50:16 +0000 (14:50 +0200)
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

index 68578aa6fe7c9c421bea0f1b9da0fa08a585c03f..91833d3f855b361d0b3cadbb7c91475fba406bee 100644 (file)
@@ -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
        {