aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2024-03-20 06:39:48 +0100
committerAldy Hernandez <aldyh@redhat.com>2024-05-04 10:25:50 +0200
commitddf039adef5e2695f1cb27e0b6e5056fef4be2ee (patch)
tree2b8b670cdf5665aa2cde025f77aac8912d5be99b
parent7c1b136630790eb34d57c45d9a816b32fd904e3f (diff)
downloadgcc-ddf039adef5e2695f1cb27e0b6e5056fef4be2ee.zip
gcc-ddf039adef5e2695f1cb27e0b6e5056fef4be2ee.tar.gz
gcc-ddf039adef5e2695f1cb27e0b6e5056fef4be2ee.tar.bz2
Add prange implementation for get_legacy_range.
gcc/ChangeLog: * value-range.cc (get_legacy_range): New version for prange.
-rw-r--r--gcc/value-range.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 62170a4..3e1ecf6 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -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}.