From: Andrew MacLeod Date: Fri, 17 Jul 2026 15:53:51 +0000 (-0400) Subject: use vrp_operand_equal_p in points to comparisons. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ddeb9b30a26ce61c836efe70893c77a67f7b737e;p=thirdparty%2Fgcc.git 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 --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc index 6a7ce4ceed3..837c40bb72e 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 e6dc59eb706..307779b37ef 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