The following avoids the need to special-case storage requirement
and copying for irange_storage_slot by making sure we canonicalize
such ranges to int_range<2>.

        * tree-ssanames.cc (range_info_set_range): If receiving
        an anti-range recurse with a temporary int_range<2>.
        * value-range-storage.cc (irange_storage_slot::size):
        Assert we're not asking for a VR_ANTI_RANGE.
---
 gcc/tree-ssanames.cc       | 3 +++
 gcc/value-range-storage.cc | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index 08aa166ef17..23468958586 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -127,6 +127,9 @@ range_info_get_range (tree name, vrange &r)
 inline bool
 range_info_set_range (tree name, const vrange &r)
 {
+  if (r.kind () == VR_ANTI_RANGE)
+    return range_info_set_range (name, int_range<2> (as_a <irange> (r)));
+
   if (!range_info_p (name) || !range_info_fits_p (name, r))
     {
       if (range_info_p (name))
diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc
index bf23f6dd476..79ab2921a03 100644
--- a/gcc/value-range-storage.cc
+++ b/gcc/value-range-storage.cc
@@ -182,7 +182,7 @@ irange_storage_slot::get_irange (irange &r, tree type) const
 size_t
 irange_storage_slot::size (const irange &r)
 {
-  gcc_checking_assert (!r.undefined_p ());
+  gcc_checking_assert (!r.undefined_p () && r.kind () != VR_ANTI_RANGE);
 
   unsigned prec = TYPE_PRECISION (r.type ());
   unsigned n = num_wide_ints_needed (r);
-- 
2.35.3

Reply via email to