aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-range.h
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2022-09-14 06:58:35 +0200
committerAldy Hernandez <aldyh@redhat.com>2022-09-14 17:06:48 +0200
commit9c4c4186eb7ca0a62fc590edcbb3f8fc9a081e64 (patch)
tree2e83a9a76cc97b9f29f58787da442680e094a660 /gcc/value-range.h
parent6da65479fcd86c21d0f6b731dda763b574e8066c (diff)
downloadgcc-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/value-range.h')
-rw-r--r--gcc/value-range.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 0ba0193..6e896eb 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -348,6 +348,7 @@ public:
virtual void set (tree, tree, value_range_kind = VR_RANGE) override;
void set (tree type, const REAL_VALUE_TYPE &, const REAL_VALUE_TYPE &,
value_range_kind = VR_RANGE);
+ void set_nan (tree type);
virtual void set_varying (tree type) override;
virtual void set_undefined () override;
virtual bool union_ (const vrange &) override;
@@ -376,7 +377,8 @@ public:
bool known_signbit (bool &signbit) const;
// Accessors for FP properties.
- void set_nan (fp_prop::kind f);
+ void update_nan (fp_prop::kind f);
+ void clear_nan () { update_nan (fp_prop::NO); }
void set_signbit (fp_prop::kind);
private:
fp_prop get_nan () const { return m_props.get_nan (); }
@@ -1186,13 +1188,12 @@ real_min_representable (REAL_VALUE_TYPE *r, tree type)
// Build a NAN of type TYPE.
-inline frange
-frange_nan (tree type)
+inline void
+frange::set_nan (tree type)
{
REAL_VALUE_TYPE r;
-
gcc_assert (real_nan (&r, "", 1, TYPE_MODE (type)));
- return frange (type, r, r);
+ set (type, r, r);
}
// Return TRUE if range is known to be finite.