https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126218
Bug ID: 126218
Summary: builtin_memref::extend_offset_range uses
get_legacy_range
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: internal-improvement
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
if (TREE_CODE (offset) == SSA_NAME)
{
/* A pointer offset is represented as sizetype but treated
as signed. */
wide_int min, max;
value_range_kind rng = VR_VARYING;
int_range_max vr;
if (m_ptr_qry.rvals->range_of_expr (vr, offset, stmt))
{
tree vr_min, vr_max;
rng = get_legacy_range (vr, vr_min, vr_max);
if (!vr.undefined_p ())
{
min = wi::to_wide (vr_min);
max = wi::to_wide (vr_max);
}
}
if (rng == VR_ANTI_RANGE && wi::lts_p (max, min))
{
/* Convert an anti-range whose upper bound is less than
its lower bound to a signed range. */
offrange[0] += offset_int::from (max + 1, SIGNED);
offrange[1] += offset_int::from (min - 1, SIGNED);
return;
}
if (rng == VR_RANGE
&& (DECL_P (base) || wi::lts_p (min, max)))
{
/* Preserve the bounds of the range for an offset into
a known object (it may be adjusted later relative to
a constant offset from its beginning). Otherwise use
the bounds only when they are ascending when treated
as signed. */
offrange[0] += offset_int::from (min, SIGNED);
offrange[1] += offset_int::from (max, SIGNED);
return;
}