[Mesa-dev] [PATCH 4/5] nir: add a helper for finding duplicate instructions

Pohjolainen, Topi topi.pohjolainen at intel.com
Mon Jun 1 03:29:58 PDT 2015


On Fri, May 22, 2015 at 02:24:51PM -0400, Connor Abbott wrote:
> This can be used for both CSE and value numbering.
> 
> Signed-off-by: Connor Abbott <cwabbott0 at gmail.com>
> ---
>  src/glsl/Makefile.sources     |   2 +
>  src/glsl/nir/nir_instr_hash.c | 255 ++++++++++++++++++++++++++++++++++++++++++
>  src/glsl/nir/nir_instr_hash.h |  36 ++++++
>  3 files changed, 293 insertions(+)
>  create mode 100644 src/glsl/nir/nir_instr_hash.c
>  create mode 100644 src/glsl/nir/nir_instr_hash.h
> 
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index 75e5377..fd10cdd 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -28,6 +28,8 @@ NIR_FILES = \
>  	nir/nir_dominance.c \
>  	nir/nir_from_ssa.c \
>  	nir/nir_instr_compare.c \
> +	nir/nir_instr_hash.c \
> +	nir/nir_instr_hash.h \
>  	nir/nir_intrinsics.c \
>  	nir/nir_intrinsics.h \
>  	nir/nir_live_variables.c \
> diff --git a/src/glsl/nir/nir_instr_hash.c b/src/glsl/nir/nir_instr_hash.c
> new file mode 100644
> index 0000000..d900b66
> --- /dev/null
> +++ b/src/glsl/nir/nir_instr_hash.c
> @@ -0,0 +1,255 @@
> +#include "nir_instr_hash.h"
> +
> +#define HASH(data) hash = _mesa_fnv32_1a_accumulate(hash, (data))

I don't know how other people feel, but I would be more comfortable with
having the destination as explicit argument as well:

#define HASH(hash, data) (hash) = _mesa_fnv32_1a_accumulate(hash, data)


More information about the mesa-dev mailing list