[Mesa-dev] [PATCH 6/7] nir: Prehash in instr_set to avoid unnecessary hashing
Jason Ekstrand
jason at jlekstrand.net
Thu Feb 2 22:58:26 UTC 2017
On Thu, Feb 2, 2017 at 12:57 PM, Thomas Helland <thomashelland90 at gmail.com>
wrote:
> This should prove benefitial in the common case of inserting
> and not rewriting anything.
> ---
> src/compiler/nir/nir_instr_set.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_instr_set.c
> b/src/compiler/nir/nir_instr_set.c
> index 9cb9ed43e8..4c45d051f8 100644
> --- a/src/compiler/nir/nir_instr_set.c
> +++ b/src/compiler/nir/nir_instr_set.c
> @@ -508,7 +508,11 @@ 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 = instr_set->key_hash_function(instr);
>
We know what the hash function is (it's hash_instr). There's no reason why
we need to go through function pointer.
> +
> + 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 +530,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.11.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170202/89d6651b/attachment.html>
More information about the mesa-dev
mailing list