aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-range.h
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2020-11-09 13:12:55 +0100
committerAldy Hernandez <aldyh@redhat.com>2020-11-09 15:42:10 +0100
commit4e85ad79a137535393d8dc169359e1730cab3533 (patch)
tree807f1f89053079a2680caf8d8695fe292bac0282 /gcc/value-range.h
parentfa59c8dcd2f97c929150bd32bae1f341e0d7b0f7 (diff)
downloadgcc-4e85ad79a137535393d8dc169359e1730cab3533.zip
gcc-4e85ad79a137535393d8dc169359e1730cab3533.tar.gz
gcc-4e85ad79a137535393d8dc169359e1730cab3533.tar.bz2
Cleanup irange::set.
[This is actually part of a larger patch that actually changes behavior, but I thought I'd commit the non-invasive cleanups first which will simplify the upcoming work.] irange::set was doing more work than it should for legacy ranges. I cleaned up various unnecessary calls to swap_out_of_order_endpoints, as well as some duplicate code that could be done with normalize_min_max. I also removed an obsolete comment wrt sticky infinite overflows. Not only did the -INF/+INF(OVF) code get removed in 2017, but normalize_min_max() uses wide ints, which ignored overflows altogether. gcc/ChangeLog: * value-range.cc (irange::swap_out_of_order_endpoints): Rewrite into static function. (irange::set): Cleanup redundant manipulations. * value-range.h (irange::normalize_min_max): Modify object in-place instead of modifying arguments.
Diffstat (limited to 'gcc/value-range.h')
-rw-r--r--gcc/value-range.h28
1 files changed, 13 insertions, 15 deletions
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 760ee77..a483fc8 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -111,8 +111,7 @@ protected:
void irange_set (tree, tree);
void irange_set_anti_range (tree, tree);
- bool swap_out_of_order_endpoints (tree &min, tree &max, value_range_kind &);
- bool normalize_min_max (tree type, tree min, tree max, value_range_kind);
+ void normalize_min_max ();
bool legacy_mode_p () const;
bool legacy_equal_p (const irange &) const;
@@ -566,7 +565,7 @@ irange::set_zero (tree type)
irange_set (z, z);
}
-// Normalize [MIN, MAX] into VARYING and ~[MIN, MAX] into UNDEFINED.
+// Normalize a range to VARYING or UNDEFINED if possible.
//
// Avoid using TYPE_{MIN,MAX}_VALUE because -fstrict-enums can
// restrict those to a subset of what actually fits in the type.
@@ -575,24 +574,23 @@ irange::set_zero (tree type)
// whereas if we used TYPE_*_VAL, said function would just punt upon
// seeing a VARYING.
-inline bool
-irange::normalize_min_max (tree type, tree min, tree max,
- value_range_kind kind)
+inline void
+irange::normalize_min_max ()
{
- unsigned prec = TYPE_PRECISION (type);
- signop sign = TYPE_SIGN (type);
- if (wi::eq_p (wi::to_wide (min), wi::min_value (prec, sign))
- && wi::eq_p (wi::to_wide (max), wi::max_value (prec, sign)))
+ gcc_checking_assert (legacy_mode_p ());
+ gcc_checking_assert (!undefined_p ());
+ unsigned prec = TYPE_PRECISION (type ());
+ signop sign = TYPE_SIGN (type ());
+ if (wi::eq_p (wi::to_wide (min ()), wi::min_value (prec, sign))
+ && wi::eq_p (wi::to_wide (max ()), wi::max_value (prec, sign)))
{
- if (kind == VR_RANGE)
- set_varying (type);
- else if (kind == VR_ANTI_RANGE)
+ if (m_kind == VR_RANGE)
+ set_varying (type ());
+ else if (m_kind == VR_ANTI_RANGE)
set_undefined ();
else
gcc_unreachable ();
- return true;
}
- return false;
}
// Return the maximum value for TYPE.