[Mesa-dev] [PATCH 2/6] nir: Prehash in instr_set to avoid hashing twice
Thomas Helland
thomashelland90 at gmail.com
Mon May 22 18:55:41 UTC 2017
This should prove benefitial in the common case of inserting
and not rewriting anything.
V2: Use hash_instr directly instead of going through the function
pointer embedded in the set
---
src/compiler/nir/nir_instr_set.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c
index 9cb9ed43e8..bdc3b02173 100644
--- a/src/compiler/nir/nir_instr_set.c
+++ b/src/compiler/nir/nir_instr_set.c
@@ -508,7 +508,10 @@ nir_instr_set_add_or_rewrite(struct set *instr_set, nir_instr *instr)
if (!instr_can_rewrite(instr))
return false;
- struct set_entry *entry = _mesa_set_search(instr_set, instr);
+ uint32_t hash = hash_instr(instr);
+ struct set_entry *entry =
+ _mesa_set_search_pre_hashed(instr_set, hash, instr);
+
if (entry) {
nir_ssa_def *def = nir_instr_get_dest_ssa_def(instr);
nir_instr *match = (nir_instr *) entry->key;
@@ -526,7 +529,7 @@ nir_instr_set_add_or_rewrite(struct set *instr_set, nir_instr *instr)
return true;
}
- _mesa_set_add(instr_set, instr);
+ _mesa_set_add_pre_hashed(instr_set, hash, instr);
return false;
}
--
2.13.0
More information about the mesa-dev
mailing list