https://gcc.gnu.org/g:ddeb9b30a26ce61c836efe70893c77a67f7b737e
commit r17-2518-gddeb9b30a26ce61c836efe70893c77a67f7b737e Author: Andrew MacLeod <[email protected]> Date: Fri Jul 17 11:53:51 2026 -0400 use vrp_operand_equal_p in points to comparisons. IPA iunshares points-to info for prange storage objects. This means they may point to the same logical object, but have different physical pointer values. A prange_storage object is a hunk of memory, and it will continue to use raw pointer comparisons for equality. Otherwise things like hash table lookups will think there are different hashs for the same item. Prange however should use vrp_operand_equal_p for comparisons. This will prevent two prange objects from comparing unequal due to tree unsharing. PR tree-optimization/126222 * value-range-storage.cc (prange_storage::equal_p): Comment change. * value-range.h (prange::pt_equal_p): Use vrp_operand_equal_p. Diff: --- gcc/value-range-storage.cc | 1 + gcc/value-range.h | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc index 6a7ce4ceed3c..837c40bb72e6 100644 --- a/gcc/value-range-storage.cc +++ b/gcc/value-range-storage.cc @@ -817,6 +817,7 @@ prange_storage::equal_p (const prange &r) const if (m_pt != r.m_pt) return false; + // Storage objects are only equal If they point to the same memory. if (m_points_to_p != r.m_points_to_p) return false; diff --git a/gcc/value-range.h b/gcc/value-range.h index e6dc59eb7066..307779b37ef7 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -1519,7 +1519,11 @@ prange::pt_unknown_p () const inline bool prange::pt_equal_p (const prange &p) const { - return (m_points_to_p == p.m_points_to_p && m_pt == p.m_pt); + // A prange object invokes vrp_operand_equal_p as we want ranges to compare + // equal to each other if they refer to the same object, even if the + // tree has become unshared. + return (m_points_to_p == p.m_points_to_p + && vrp_operand_equal_p (m_pt, p.m_pt)); } inline bool
