Add prange implementation for get_legacy_range.

gcc/ChangeLog:

	* value-range.cc (get_legacy_range): New version for prange.
This commit is contained in:
Aldy Hernandez 2024-03-20 06:39:48 +01:00
parent 7c1b136630
commit ddf039adef

View 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}.