diff mbox series

[01/13] scoped tables: insert before further lookups

Message ID or1qolh455.fsf@lxoliva.fsfla.org
State New
Headers show
Series [01/13] scoped tables: insert before further lookups | expand

Commit Message

Alexandre Oliva Dec. 27, 2022, 4:17 a.m. UTC
Avoid hash table lookups between requesting an insert and storing the
inserted value in avail_exprs_stack.  Lookups before the insert is
completed could fail to find double-hashed elements.

Regstrapped on x86_64-linux-gnu.  Ok to install?


for  gcc/ChangeLog

	* tree-ssa-scopedtables.cc
	(avail_exprs_stack::lookup_avail_expr): Finish hash table
	insertion before further lookups.
---
 gcc/tree-ssa-scopedtables.cc |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Jeff Law Dec. 27, 2022, 3:11 p.m. UTC | #1
On 12/26/22 21:17, Alexandre Oliva via Gcc-patches wrote:
> 
> Avoid hash table lookups between requesting an insert and storing the
> inserted value in avail_exprs_stack.  Lookups before the insert is
> completed could fail to find double-hashed elements.
> 
> Regstrapped on x86_64-linux-gnu.  Ok to install?
> 
> 
> for  gcc/ChangeLog
> 
> 	* tree-ssa-scopedtables.cc
> 	(avail_exprs_stack::lookup_avail_expr): Finish hash table
> 	insertion before further lookups.
Thanks.  OK.
Jeff
diff mbox series

Patch

diff --git a/gcc/tree-ssa-scopedtables.cc b/gcc/tree-ssa-scopedtables.cc
index 6d203ef89ecef..3e6e129e7d5d3 100644
--- a/gcc/tree-ssa-scopedtables.cc
+++ b/gcc/tree-ssa-scopedtables.cc
@@ -259,11 +259,6 @@  avail_exprs_stack::lookup_avail_expr (gimple *stmt, bool insert, bool tbaa_p,
     }
   else if (*slot == NULL)
     {
-      /* If we did not find the expression in the hash table, we may still
-	 be able to produce a result for some expressions.  */
-      tree retval = avail_exprs_stack::simplify_binary_operation (stmt,
-								  element);
-
       /* We have, in effect, allocated *SLOT for ELEMENT at this point.
 	 We must initialize *SLOT to a real entry, even if we found a
 	 way to prove ELEMENT was a constant after not finding ELEMENT
@@ -277,6 +272,11 @@  avail_exprs_stack::lookup_avail_expr (gimple *stmt, bool insert, bool tbaa_p,
       class expr_hash_elt *element2 = new expr_hash_elt (element);
       *slot = element2;
 
+      /* If we did not find the expression in the hash table, we may still
+	 be able to produce a result for some expressions.  */
+      tree retval = avail_exprs_stack::simplify_binary_operation (stmt,
+								  element);
+
       record_expr (element2, NULL, '2');
       return retval;
     }