From 9c4c4186eb7ca0a62fc590edcbb3f8fc9a081e64 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Wed, 14 Sep 2022 06:58:35 +0200 Subject: 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. --- gcc/value-query.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/value-query.cc') diff --git a/gcc/value-query.cc b/gcc/value-query.cc index de83f46..ea6e4b9 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -223,9 +223,9 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt) // Singletons from the tree world have known properties. REAL_VALUE_TYPE *rv = TREE_REAL_CST_PTR (expr); if (real_isnan (rv)) - f.set_nan (fp_prop::YES); + f.update_nan (fp_prop::YES); else - f.set_nan (fp_prop::NO); + f.clear_nan (); if (real_isneg (rv)) f.set_signbit (fp_prop::YES); else -- cgit v1.1