https://gcc.gnu.org/g:f8f19f11571d0698449a3b71a8b355be6fccc4b3

commit r17-2470-gf8f19f11571d0698449a3b71a8b355be6fccc4b3
Author: Andrew MacLeod <[email protected]>
Date:   Wed Jul 15 15:43:14 2026 -0400

    Path ranger should check root ranger equivalencies as well.
    
    Path ranger currently checks the root ranger for realtions between
    only local equivalencies.   If that fails, it should also check the
    root ranger for any equivalencies and relations between the two names
    which occur earlier in the IL.
    
            PR tree-optimization/125986
            * value-relation.cc (path_oracle::query): Query root oracle for
            relations.

Diff:
---
 gcc/value-relation.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index 932bb070dad4..3ad522ccf646 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -1710,6 +1710,7 @@ path_oracle::query (basic_block bb, const_bitmap b1, 
const_bitmap b2)
       || bitmap_intersect_p (m_killed_defs, b2))
     return k;
 
+  // Query the root oracle for relations with path local equivalencies.
   if (k == VREL_VARYING && m_root)
     k = m_root->query (bb, b1, b2);
 
@@ -1733,7 +1734,12 @@ path_oracle::query (basic_block bb, tree ssa1, tree ssa2)
   if (bitmap_bit_p (equiv_1, v2) && bitmap_bit_p (equiv_2, v1))
     return VREL_EQ;
 
-  return query (bb, equiv_1, equiv_2);
+  relation_kind rel = query (bb, equiv_1, equiv_2);
+
+  // If the path relation query fails, check for relations in the root oracle.
+  if (rel == VREL_VARYING && m_root)
+      rel = m_root->query (bb, ssa1, ssa2);
+  return rel;
 }
 
 // Reset any relations registered on this path.  ORACLE is the root

Reply via email to