https://gcc.gnu.org/g:189b0202e2664ea06e17c5424d2d17151607ee2d

commit r17-4936-g189b0202e2664ea06e17c5424d2d17151607ee2d
Author: Andrew MacLeod <[email protected]>
Date:   Tue Oct 6 10:05:59 2026 -0400

    Check free list before using a relation.
    
    Rather than calling reset_range_Info in release_ssa_name_fn, lazily
    check the free list when registering nearest relations to avoid returning
    a relation with a released ssa-name.
    
            PR tree-optimization/127719
            gcc/
            * tree-ssanames.cc (release_ssa_name_fn): Do not call
            reset_range_info.
            * value-relation.cc (dom_oracle::nearest_relations): Check the
            free list before adding a name to the relation list.

Diff:
---
 gcc/tree-ssanames.cc  | 5 -----
 gcc/value-relation.cc | 6 ++++--
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index 603bdc430980..8eac57f42cba 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -692,11 +692,6 @@ release_ssa_name_fn (struct function *fn, tree var)
       int saved_ssa_name_version = SSA_NAME_VERSION (var);
       use_operand_p imm = &(SSA_NAME_IMM_USE_NODE (var));
 
-      /* An active range query caches information keyed off both VAR and its
-        version, communicate that this node is about to be cleared.  */
-      if (fn->x_range_query)
-       fn->x_range_query->reset_range_info (var);
-
       if (MAY_HAVE_DEBUG_BIND_STMTS)
        insert_debug_temp_for_var_def (NULL, var);
 
diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index cfef9fcd68d8..be4f1aaf784e 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -1857,9 +1857,11 @@ dom_oracle::nearest_relations (tree name, basic_block bb)
       for (relation_chain *ptr = m_relations[bb->index].m_head;
           ptr; ptr = ptr->m_next)
        {
-         if (v == SSA_NAME_VERSION (ptr->op1 ()))
+         if (v == SSA_NAME_VERSION (ptr->op1 ())
+             && !SSA_NAME_IN_FREE_LIST (ptr->op2 ()))
            m_near.safe_push ({ ptr->kind (), ptr->op2 (), bb });
-         else if (v == SSA_NAME_VERSION (ptr->op2 ()))
+         else if (v == SSA_NAME_VERSION (ptr->op2 ())
+                  && !SSA_NAME_IN_FREE_LIST (ptr->op1 ()))
            m_near.safe_push ({ relation_swap (ptr->kind ()),
                                ptr->op1 (), bb });
        }

Reply via email to