[gcc/devel/jlaw/pr90036.new] [1/n][PR tree-optimization/90036] All refinement of entries in DOM hash table
Jeff Law
law@gcc.gnu.org
Wed Mar 11 15:34:00 GMT 2026
https://gcc.gnu.org/g:46b0e4e96545042dddf42fd543a0fa6c81e9eee9
commit 46b0e4e96545042dddf42fd543a0fa6c81e9eee9
Author: Jeff Law <jeffrey.law@oss.qualcomm.com>
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.
(cherry picked from commit 55c6baeb86b10912e98f4cf6b0a432d7c896d81e)
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
More information about the Gcc-cvs
mailing list