[Mesa-dev] [PATCH 5/6] glsl: Prehash to avoid computing the hash twice

Thomas Helland thomashelland90 at gmail.com
Mon May 22 18:55:44 UTC 2017


Copy propagation elements is a large user of the hash table.
We should not be computing the hash twice when we don't have to.
---
 src/compiler/glsl/opt_copy_propagation_elements.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/opt_copy_propagation_elements.cpp b/src/compiler/glsl/opt_copy_propagation_elements.cpp
index 9f79fa9202..d318417f6c 100644
--- a/src/compiler/glsl/opt_copy_propagation_elements.cpp
+++ b/src/compiler/glsl/opt_copy_propagation_elements.cpp
@@ -498,8 +498,11 @@ ir_copy_propagation_elements_visitor::visit_enter(ir_loop *ir)
 void
 ir_copy_propagation_elements_visitor::kill(kill_entry *k)
 {
+   uint32_t hash = lhs_ht->key_hash_function(k->var);
    /* removal of lhs entries */
-   hash_entry *ht_entry = _mesa_hash_table_search(lhs_ht, k->var);
+   hash_entry *ht_entry =
+         _mesa_hash_table_search_pre_hashed(lhs_ht, hash, k->var);
+
    if (ht_entry) {
       exec_list *lhs_list = (exec_list *) ht_entry->data;
       foreach_in_list_safe(acp_entry, entry, lhs_list) {
@@ -512,7 +515,7 @@ ir_copy_propagation_elements_visitor::kill(kill_entry *k)
    }
 
    /* removal of rhs entries */
-   ht_entry = _mesa_hash_table_search(rhs_ht, k->var);
+   ht_entry = _mesa_hash_table_search_pre_hashed(rhs_ht, hash, k->var);
    if (ht_entry) {
       exec_list *rhs_list = (exec_list *) ht_entry->data;
       acp_ref *ref;
-- 
2.13.0



More information about the mesa-dev mailing list