https://gcc.gnu.org/g:55c6baeb86b10912e98f4cf6b0a432d7c896d81e
commit r16-7761-g55c6baeb86b10912e98f4cf6b0a432d7c896d81e Author: Jeff Law <[email protected]> Date: Sun Feb 22 09:26:38 2026 -0700 [1/n][PR tree-optimization/90036] All refinement of entries in DOM hash table This is the first of a few patches to fix pr90036. I've gone back and forth about whether or not to fix this for gcc-16 or queue for gcc-17. Ultimately I don't think these opportunities are *that* common, so I don't expect widespread code generation changes. I'm going to drop the changes in a small series as the changes stand on their own. This gives us better bisectability. -- The first patch allows refinement of existing equivalences in a case where we'd missed it before. In particular say we have <res> = <expr> in the expression hash table. We later use <expr> in a way that creates a temporary expression equivalence. We'll fail to record that temporary expression equivalence because of the pre-existing entry in the hash table. And just to be clear, the old equivalence will be restored when we leave the domwalk scope of the newer, more precise, hash table entry. This matters for pr90036 as we initially enter a simple equivalence in the table with the result being an SSA_NAME. Later we have a conditional that allows us to refine the result to a constant. And we're going to need that constant result to trigger additional simplifications and equivalence discovery. Bootstrapped and regression tested on x86_64, aarch64, riscv64 and probably a couple others as well. It's also been tested across the embedded targets in my tester. Pushing to the trunk. PR tree-optimization/90036 gcc/ * tree-ssa-scopedtables.cc (avail_exprs_stack::record_cond): Always record the new hash table entry. Diff: --- gcc/tree-ssa-scopedtables.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/tree-ssa-scopedtables.cc b/gcc/tree-ssa-scopedtables.cc index 828f214c7cbe..95523b23478b 100644 --- a/gcc/tree-ssa-scopedtables.cc +++ b/gcc/tree-ssa-scopedtables.cc @@ -392,13 +392,13 @@ avail_exprs_stack::record_cond (cond_equivalence *p) expr_hash_elt **slot; slot = m_avail_exprs->find_slot_with_hash (element, element->hash (), INSERT); - if (*slot == NULL) - { - *slot = element; - record_expr (element, NULL, '1'); - } - else - delete element; + + /* We will always get back a valid slot in the hash table. Go ahead and + record the new equivalence. While it may be overwriting something older, + the belief is that the newer equivalence is more likely to be useful as + it was derived using more information/context. */ + record_expr (element, *slot, '1'); + *slot = element; } /* Generate a hash value for a pair of expressions. This can be used
