diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2022-09-14 06:58:35 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2022-09-14 17:06:48 +0200 |
commit | 9c4c4186eb7ca0a62fc590edcbb3f8fc9a081e64 (patch) | |
tree | 2e83a9a76cc97b9f29f58787da442680e094a660 /gcc/range-op-float.cc | |
parent | 6da65479fcd86c21d0f6b731dda763b574e8066c (diff) | |
download | gcc-9c4c4186eb7ca0a62fc590edcbb3f8fc9a081e64.zip gcc-9c4c4186eb7ca0a62fc590edcbb3f8fc9a081e64.tar.gz gcc-9c4c4186eb7ca0a62fc590edcbb3f8fc9a081e64.tar.bz2 |
Provide cleaner set_nan(), clear_nan(), and update_nan() methods.
set_* has a very specific meaning for irange's and friends. Methods
prefixed with set_* are setters clobbering the existing range. As
such, the current set_nan() method is confusing in that it's not
actually setting a range to a NAN, but twiddling the NAN flags for an
existing frange.
This patch replaces set_nan() with an update_nan() to set the flag,
and clear_nan() to clear it. This makes the code clearer, and though
the confusing tristate is still there, it will be removed in upcoming
patches.
Also, there is now an actual set_nan() method to set the range to a
NAN. This replaces two out of class functions doing the same thing.
In future patches I will also add the ability to create a NAN with a
specific sign, but doing so now would be confusing because we're not
tracking NAN signs.
We should also submit set_signbit to the same fate, but it's about to
get removed.
No functional changes.
Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.
gcc/ChangeLog:
* range-op-float.cc (frange_set_nan): Remove.
(build_lt): Use set_nan, update_nan, clear_nan.
(build_gt): Same.
(foperator_equal::op1_range): Same.
(foperator_not_equal::op1_range): Same.
(foperator_lt::op1_range): Same.
(foperator_lt::op2_range): Same.
(foperator_le::op1_range): Same.
(foperator_le::op2_range): Same.
(foperator_gt::op1_range): Same.
(foperator_gt::op2_range): Same.
(foperator_ge::op1_range): Same.
(foperator_ge::op2_range): Same.
(foperator_unordered::op1_range): Same.
(foperator_ordered::op1_range): Same.
* value-query.cc (range_query::get_tree_range): Same.
* value-range.cc (frange::set_nan): Same.
(frange::update_nan): Same.
(frange::union_): Same.
(frange::intersect): Same.
(range_tests_nan): Same.
(range_tests_signed_zeros): Same.
(range_tests_signbit): Same.
(range_tests_floats): Same.
* value-range.h (class frange): Add update_nan and clear_nan.
(frange::set_nan): New.
Diffstat (limited to 'gcc/range-op-float.cc')
-rw-r--r-- | gcc/range-op-float.cc | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 0f928b6..f979ca5 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -150,18 +150,6 @@ range_operator_float::op1_op2_relation (const irange &lhs ATTRIBUTE_UNUSED) cons return VREL_VARYING; } -// Set R to [NAN, NAN]. - -static inline void -frange_set_nan (frange &r, tree type) -{ - REAL_VALUE_TYPE rv; - bool res = real_nan (&rv, "", 1, TYPE_MODE (type)); - if (flag_checking) - gcc_assert (res); - r.set (type, rv, rv); -} - // Return TRUE if OP1 is known to be free of NANs. static inline bool @@ -248,7 +236,7 @@ build_lt (frange &r, tree type, const REAL_VALUE_TYPE &val) if (real_isinf (&val, 1)) { if (HONOR_NANS (type)) - frange_set_nan (r, type); + r.set_nan (type); else r.set_undefined (); return false; @@ -286,7 +274,7 @@ build_gt (frange &r, tree type, const REAL_VALUE_TYPE &val) if (real_isinf (&val, 0)) { if (HONOR_NANS (type)) - frange_set_nan (r, type); + r.set_nan (type); else r.set_undefined (); return false; @@ -392,14 +380,14 @@ foperator_equal::op1_range (frange &r, tree type, if (HONOR_SIGNED_ZEROS (type) && r.contains_p (build_zero_cst (type))) r.set_signbit (fp_prop::VARYING); // The TRUE side of op1 == op2 implies op1 is !NAN. - r.set_nan (fp_prop::NO); + r.clear_nan (); break; case BRS_FALSE: r.set_varying (type); // The FALSE side of op1 == op1 implies op1 is a NAN. if (rel == VREL_EQ) - frange_set_nan (r, type); + r.set_nan (type); // If the result is false, the only time we know anything is // if OP2 is a constant. else if (op2.singleton_p () @@ -496,7 +484,7 @@ foperator_not_equal::op1_range (frange &r, tree type, if (HONOR_SIGNED_ZEROS (type) && r.contains_p (build_zero_cst (type))) r.set_signbit (fp_prop::VARYING); // The FALSE side of op1 != op2 implies op1 is !NAN. - r.set_nan (fp_prop::NO); + r.clear_nan (); break; default: @@ -563,7 +551,7 @@ foperator_lt::op1_range (frange &r, case BRS_TRUE: if (build_lt (r, type, op2.upper_bound ())) { - r.set_nan (fp_prop::NO); + r.clear_nan (); // x < y implies x is not +INF. frange_drop_inf (r, type); } @@ -591,7 +579,7 @@ foperator_lt::op2_range (frange &r, case BRS_TRUE: if (build_gt (r, type, op1.lower_bound ())) { - r.set_nan (fp_prop::NO); + r.clear_nan (); // x < y implies y is not -INF. frange_drop_ninf (r, type); } @@ -664,7 +652,7 @@ foperator_le::op1_range (frange &r, { case BRS_TRUE: if (build_le (r, type, op2.upper_bound ())) - r.set_nan (fp_prop::NO); + r.clear_nan (); break; case BRS_FALSE: @@ -688,7 +676,7 @@ foperator_le::op2_range (frange &r, { case BRS_TRUE: if (build_ge (r, type, op1.lower_bound ())) - r.set_nan (fp_prop::NO); + r.clear_nan (); break; case BRS_FALSE: @@ -759,7 +747,7 @@ foperator_gt::op1_range (frange &r, case BRS_TRUE: if (build_gt (r, type, op2.lower_bound ())) { - r.set_nan (fp_prop::NO); + r.clear_nan (); // x > y implies x is not -INF. frange_drop_ninf (r, type); } @@ -787,7 +775,7 @@ foperator_gt::op2_range (frange &r, case BRS_TRUE: if (build_lt (r, type, op1.upper_bound ())) { - r.set_nan (fp_prop::NO); + r.clear_nan (); // x > y implies y is not +INF. frange_drop_inf (r, type); } @@ -860,7 +848,7 @@ foperator_ge::op1_range (frange &r, { case BRS_TRUE: build_ge (r, type, op2.lower_bound ()); - r.set_nan (fp_prop::NO); + r.clear_nan (); break; case BRS_FALSE: @@ -887,7 +875,7 @@ foperator_ge::op2_range (frange &r, tree type, case BRS_TRUE: build_le (r, type, op1.upper_bound ()); - r.set_nan (fp_prop::NO); + r.clear_nan (); break; default: @@ -948,13 +936,13 @@ foperator_unordered::op1_range (frange &r, tree type, // Since at least one operand must be NAN, if one of them is // not, the other must be. if (!op2.maybe_nan ()) - frange_set_nan (r, type); + r.set_nan (type); break; case BRS_FALSE: r.set_varying (type); // A false UNORDERED means both operands are !NAN. - r.set_nan (fp_prop::NO); + r.clear_nan (); break; default: @@ -1011,14 +999,14 @@ foperator_ordered::op1_range (frange &r, tree type, case BRS_TRUE: r.set_varying (type); // The TRUE side of op1 ORDERED op2 implies op1 is !NAN. - r.set_nan (fp_prop::NO); + r.clear_nan (); break; case BRS_FALSE: r.set_varying (type); // The FALSE side of op1 ORDERED op1 implies op1 is !NAN. if (rel == VREL_EQ) - r.set_nan (fp_prop::NO); + r.clear_nan (); break; default: |