* [COMMITTED] Add op[12]_range for UNORDERED_LT entries in range-op.
@ 2022-10-20 19:42 Aldy Hernandez
0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2022-10-20 19:42 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez
In auditing the UNORDERED range-op code I noticed the UNLT_EXPR entry
was missing op1_range and op2_range operators. That is, we were
missing the ability to unwind back through an UNLT_EXPR.
gcc/ChangeLog:
* range-op-float.cc (foperator_unordered_lt::op1_range): New.
(foperator_unordered_lt::op2_range): New.
---
gcc/range-op-float.cc | 64 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 0cb07c2ec29..8777bc70d71 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -1280,6 +1280,8 @@ foperator_abs::op1_range (frange &r, tree type,
class foperator_unordered_lt : public range_operator_float
{
using range_operator_float::fold_range;
+ using range_operator_float::op1_range;
+ using range_operator_float::op2_range;
public:
bool fold_range (irange &r, tree type,
const frange &op1, const frange &op2,
@@ -1302,8 +1304,70 @@ public:
return true;
}
}
+ bool op1_range (frange &r, tree type,
+ const irange &lhs,
+ const frange &op2,
+ relation_trio trio) const final override;
+ bool op2_range (frange &r, tree type,
+ const irange &lhs,
+ const frange &op1,
+ relation_trio trio) const final override;
} fop_unordered_lt;
+bool
+foperator_unordered_lt::op1_range (frange &r, tree type,
+ const irange &lhs,
+ const frange &op2,
+ relation_trio) const
+{
+ switch (get_bool_state (r, lhs, type))
+ {
+ case BRS_TRUE:
+ build_lt (r, type, op2);
+ break;
+
+ case BRS_FALSE:
+ // A false UNORDERED_LT 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_ge (r, type, op2))
+ r.clear_nan ();
+ break;
+
+ default:
+ break;
+ }
+ return true;
+}
+
+bool
+foperator_unordered_lt::op2_range (frange &r, tree type,
+ const irange &lhs,
+ const frange &op1,
+ relation_trio) const
+{
+ switch (get_bool_state (r, lhs, type))
+ {
+ case BRS_TRUE:
+ build_gt (r, type, op1);
+ break;
+
+ case BRS_FALSE:
+ // A false UNORDERED_LT 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_le (r, type, op1))
+ r.clear_nan ();
+ break;
+
+ default:
+ break;
+ }
+ return true;
+}
+
class foperator_unordered_le : public range_operator_float
{
using range_operator_float::fold_range;
--
2.37.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-20 19:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 19:42 [COMMITTED] Add op[12]_range for UNORDERED_LT entries in range-op 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).