https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107569
--- Comment #33 from Aldy Hernandez <aldyh at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #31) > Created attachment 53873 [details] > gcc13-pr107569-div.patch > > This is what I meant by complete nightmare - division. We can take this to gcc-patches when you're done, but just a few thoughts... + // If +-0.0 is in both ranges, it is a maybe NAN. + if (real_compare (LE_EXPR, &lh_lb, &dconst0) + && real_compare (GE_EXPR, &lh_ub, &dconst0) + && real_compare (LE_EXPR, &rh_lb, &dconst0) + && real_compare (GE_EXPR, &rh_ub, &dconst0)) Perhaps we could provide frange::contains_zero_p ()? + // +-0.0 / +-0.0 or +-INF / +-INF is a known NAN. + if ((real_iszero (&lh_lb) + && real_iszero (&lh_ub) + && real_iszero (&rh_lb) + && real_iszero (&rh_ub)) This looks like frange::contains_zerp_p () as well. + || (real_isinf (&lh_lb) + && real_isinf (&lh_ub, real_isneg (&lh_lb)) + && real_isinf (&rh_lb) + && real_isinf (&rh_ub, real_isneg (&rh_lb)))) Note that, real_isinf with only one argument checks for +-INF. But I think what you're looking for is frange::maybe_isinf. Could your patch be simplified with some of these? // fpclassify like API bool known_isfinite () const; bool known_isnan () const; bool known_isinf () const; bool maybe_isnan () const; bool maybe_isnan (bool sign) const; bool maybe_isinf () const; bool signbit_p (bool &signbit) const; bool nan_signbit_p (bool &signbit) const; We should ultimately avoid peeking at the end points unnecessarily in order to prepare ourselves for next release when we (hopefully) have sub-ranges.