[Mesa-dev] [PATCH 2/2] glsl: Use hash table cloning in copy propagation

Eric Anholt eric at anholt.net
Mon Mar 12 18:53:26 UTC 2018


Thomas Helland <thomashelland90 at gmail.com> writes:

> Walking the whole hash table, inserting entries by hashing them first
> is just a really bad idea. We can simply memcpy the whole thing.
> ---
>  src/compiler/glsl/opt_copy_propagation.cpp         | 13 ++++------
>  .../glsl/opt_copy_propagation_elements.cpp         | 29 ++++++++--------------
>  2 files changed, 15 insertions(+), 27 deletions(-)
>
> diff --git a/src/compiler/glsl/opt_copy_propagation.cpp b/src/compiler/glsl/opt_copy_propagation.cpp
> index e904e6ede4..96667779da 100644
> --- a/src/compiler/glsl/opt_copy_propagation.cpp
> +++ b/src/compiler/glsl/opt_copy_propagation.cpp
> @@ -220,10 +220,7 @@ ir_copy_propagation_visitor::handle_if_block(exec_list *instructions)
>     this->killed_all = false;
>  
>     /* Populate the initial acp with a copy of the original */
> -   struct hash_entry *entry;
> -   hash_table_foreach(orig_acp, entry) {
> -      _mesa_hash_table_insert(acp, entry->key, entry->data);
> -   }
> +   acp = _mesa_hash_table_clone(orig_acp, NULL);

Remove creation of acp above

>  
>     visit_list_elements(this, instructions);
>  
> @@ -271,10 +268,10 @@ ir_copy_propagation_visitor::handle_loop(ir_loop *ir, bool keep_acp)
>     this->killed_all = false;
>  
>     if (keep_acp) {
> -      struct hash_entry *entry;
> -      hash_table_foreach(orig_acp, entry) {
> -         _mesa_hash_table_insert(acp, entry->key, entry->data);
> -      }
> +      acp = _mesa_hash_table_clone(orig_acp, NULL);
> +   } else {
> +      acp = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
> +                                    _mesa_key_pointer_equal);
>     }

Again, remove the old creation of the acp.

Other than that, these are:

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180312/0740d917/attachment.sig>


More information about the mesa-dev mailing list