public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3415] A false UNORDERED_<cond> means neither operand can be a NAN.
@ 2022-10-20 16:46 Aldy Hernandez
0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2022-10-20 16:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3dfdc0d1e1c4e00a77f2afc41d577c1b36cb4702
commit r13-3415-g3dfdc0d1e1c4e00a77f2afc41d577c1b36cb4702
Author: Aldy Hernandez <aldyh@redhat.com>
Date: Wed Oct 19 17:14:02 2022 +0200
A false UNORDERED_<cond> means neither operand can be a NAN.
The false side of UNORDERED_<cond> means neither operand can be a NAN.
Adjust all the op[12]_range entries for the UNORDERED operators such
that a known NAN on one operands means the other operands is
undefined.
gcc/ChangeLog:
* range-op-float.cc (foperator_unordered_le::op1_range): Adjust
false side with a NAN operand.
(foperator_unordered_le::op2_range): Same.
(foperator_unordered_gt::op1_range): Same.
(foperator_unordered_gt::op2_range): Same.
(foperator_unordered_ge::op1_range): Same.
(foperator_unordered_ge::op2_range): Same.
(foperator_unordered_equal::op1_range): Same.
Diff:
---
gcc/range-op-float.cc | 51 +++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 10 deletions(-)
diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index a9e74c86877..0cb07c2ec29 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -1351,7 +1351,11 @@ foperator_unordered_le::op1_range (frange &r, tree type,
break;
case BRS_FALSE:
- if (build_gt (r, type, op2))
+ // A false UNORDERED_LE means both operands are !NAN, so it's
+ // impossible for op2 to be a NAN.
+ if (op2.known_isnan ())
+ r.set_undefined ();
+ else if (build_gt (r, type, op2))
r.clear_nan ();
break;
@@ -1375,7 +1379,11 @@ foperator_unordered_le::op2_range (frange &r,
break;
case BRS_FALSE:
- if (build_lt (r, type, op1))
+ // A false UNORDERED_LE means both operands are !NAN, so it's
+ // impossible for op1 to be a NAN.
+ if (op1.known_isnan ())
+ r.set_undefined ();
+ else if (build_lt (r, type, op1))
r.clear_nan ();
break;
@@ -1434,7 +1442,11 @@ foperator_unordered_gt::op1_range (frange &r,
break;
case BRS_FALSE:
- if (build_le (r, type, op2))
+ // A false UNORDERED_GT means both operands are !NAN, so it's
+ // impossible for op2 to be a NAN.
+ if (op2.known_isnan ())
+ r.set_undefined ();
+ else if (build_le (r, type, op2))
r.clear_nan ();
break;
@@ -1458,7 +1470,11 @@ foperator_unordered_gt::op2_range (frange &r,
break;
case BRS_FALSE:
- if (build_ge (r, type, op1))
+ // A false UNORDERED_GT means both operands are !NAN, so it's
+ // impossible for op1 to be a NAN.
+ if (op1.known_isnan ())
+ r.set_undefined ();
+ else if (build_ge (r, type, op1))
r.clear_nan ();
break;
@@ -1517,7 +1533,11 @@ foperator_unordered_ge::op1_range (frange &r,
break;
case BRS_FALSE:
- if (build_lt (r, type, op2))
+ // A false UNORDERED_GE means both operands are !NAN, so it's
+ // impossible for op2 to be a NAN.
+ if (op2.known_isnan ())
+ r.set_undefined ();
+ else if (build_lt (r, type, op2))
r.clear_nan ();
break;
@@ -1540,7 +1560,11 @@ foperator_unordered_ge::op2_range (frange &r, tree type,
break;
case BRS_FALSE:
- if (build_gt (r, type, op1))
+ // A false UNORDERED_GE means both operands are !NAN, so it's
+ // impossible for op1 to be a NAN.
+ if (op1.known_isnan ())
+ r.set_undefined ();
+ else if (build_gt (r, type, op1))
r.clear_nan ();
break;
@@ -1606,10 +1630,17 @@ foperator_unordered_equal::op1_range (frange &r, tree type,
break;
case BRS_FALSE:
- // The false side indictates !NAN and not equal. We can at least
- // represent !NAN.
- r.set_varying (type);
- r.clear_nan ();
+ // A false UNORDERED_EQ means both operands are !NAN, so it's
+ // impossible for op2 to be a NAN.
+ if (op2.known_isnan ())
+ r.set_undefined ();
+ else
+ {
+ // The false side indictates !NAN and not equal. We can at least
+ // represent !NAN.
+ r.set_varying (type);
+ r.clear_nan ();
+ }
break;
default:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-20 16:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 16:46 [gcc r13-3415] A false UNORDERED_<cond> means neither operand can be a NAN Aldy Hernandez
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).