]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add prange implementation for get_legacy_range.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 20 Mar 2024 05:39:48 +0000 (06:39 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Sat, 4 May 2024 08:25:50 +0000 (10:25 +0200)
gcc/ChangeLog:

* value-range.cc (get_legacy_range): New version for prange.

gcc/value-range.cc

index 62170a438bf4ed5ef5e750b87875e992f004a582..3e1ecf69517cdba92995b18930e1420b6034fe8a 100644 (file)
@@ -1377,6 +1377,38 @@ get_legacy_range (const irange &r, tree &min, tree &max)
   return VR_RANGE;
 }
 
+static value_range_kind
+get_legacy_range (const prange &r, tree &min, tree &max)
+{
+  if (r.undefined_p ())
+    {
+      min = NULL_TREE;
+      max = NULL_TREE;
+      return VR_UNDEFINED;
+    }
+
+  tree type = r.type ();
+  if (r.varying_p ())
+    {
+      min = r.lbound ();
+      max = r.ubound ();
+      return VR_VARYING;
+    }
+  if (r.zero_p ())
+    {
+      min = max = r.lbound ();
+      return VR_RANGE;
+    }
+  if (r.nonzero_p ())
+    {
+      min = max = build_zero_cst (type);
+      return VR_ANTI_RANGE;
+    }
+  min = r.lbound ();
+  max = r.ubound ();
+  return VR_RANGE;
+}
+
 // Given a range in V, return an old-style legacy range consisting of
 // a value_range_kind with a MIN/MAX.  This is to maintain
 // compatibility with passes that still depend on VR_ANTI_RANGE, and
@@ -1388,8 +1420,7 @@ get_legacy_range (const vrange &v, tree &min, tree &max)
   if (is_a <irange> (v))
     return get_legacy_range (as_a <irange> (v), min, max);
 
-  gcc_unreachable ();
-  return VR_UNDEFINED;
+  return get_legacy_range (as_a <prange> (v), min, max);
 }
 
 /* Set value range to the canonical form of {VRTYPE, MIN, MAX, EQUIV}.