aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2023-08-25 18:21:16 +0200
committerAldy Hernandez <aldyh@redhat.com>2023-08-28 08:11:47 +0200
commit979e0fbf53cdf5ea2b885ddbb1369bfd3a7402f4 (patch)
treed7c10106b15a10e2b7c3a0771507a45e6c24660d /gcc
parentc28c579f0dd9cd27f90df9aff7cbdb2db1c23b3b (diff)
downloadgcc-979e0fbf53cdf5ea2b885ddbb1369bfd3a7402f4.zip
gcc-979e0fbf53cdf5ea2b885ddbb1369bfd3a7402f4.tar.gz
gcc-979e0fbf53cdf5ea2b885ddbb1369bfd3a7402f4.tar.bz2
[frange] Handle relations in LTGT_EXPR.
LTGT_EXPR hasn't been handling relations, especially with NANs as a possibility. This handles them while documenting how relations work in a world with NANs. Basically we need to special case VREL_EQ before calling frelop_early_resolve. Note that VREL_EQ on entry to a range-op entry is really VREL_EQ U NAN, but to make sure about the NAN possibility, one must look at the operands. However, even VREL_EQ U NAN is false for LTGT_EXPR since the latter is just NE_EXPR without a NAN. After we handle VREL_EQ, we drop down to frelop_early_resolve pretending to be a NE_EXPR, and everything should just map correctly. 2023-08-28 Aldy Hernandez <aldyh@redhat.com> * range-op-float.cc (fold_range): Handle relations.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/range-op-float.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 1419964..eebc73f99 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -2204,8 +2204,23 @@ class foperator_ltgt : public range_operator
public:
bool fold_range (irange &r, tree type,
const frange &op1, const frange &op2,
- relation_trio rel = TRIO_VARYING) const final override
+ relation_trio trio = TRIO_VARYING) const final override
{
+ relation_kind rel = trio.op1_op2 ();
+
+ // VREL_EQ is really VREL_(UN)EQ because we could have a NAN in
+ // the operands, but since LTGT_EXPR is really a NE_EXPR without
+ // the NAN, VREL_EQ & LTGT_EXPR is an impossibility.
+ if (rel == VREL_EQ)
+ {
+ r = range_false (type);
+ return true;
+ }
+ // ...otherwise pretend we're trying to resolve a NE_EXPR and
+ // everything will "just work".
+ if (frelop_early_resolve (r, type, op1, op2, trio, VREL_NE))
+ return true;
+
if (op1.known_isnan () || op2.known_isnan ())
{
r = range_false (type);
@@ -2218,7 +2233,7 @@ public:
if (op2.maybe_isnan ())
op2_no_nan.clear_nan ();
if (!range_op_handler (NE_EXPR).fold_range (r, type, op1_no_nan,
- op2_no_nan, rel))
+ op2_no_nan, trio))
return false;
// The result is the same as the ordered version when the
// comparison is true or when the operands cannot be NANs.