]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
use vrp_operand_equal_p in points to comparisons.
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 17 Jul 2026 15:53:51 +0000 (11:53 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Sun, 19 Jul 2026 01:37:31 +0000 (21:37 -0400)
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.

gcc/value-range-storage.cc
gcc/value-range.h

index 6a7ce4ceed3c60b9a9f847fd19082d5012200810..837c40bb72e63b3bc6b0a4432febf94193cf1faf 100644 (file)
@@ -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;
 
index e6dc59eb70665e3257d866fbb75aa5e66ed0c647..307779b37ef7350ffdb694c60c4a59464383c761 100644 (file)
@@ -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