From 3aa29c47b9f8c435a89ce622a4dfb034350a3f38 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 1 Jul 2024 17:01:08 +0100 Subject: [PATCH] nir/instr_set: hash tex sources commutatively I'm not sure if two otherwise equal texture instructions ever have sources in different orders, but they should be considered equal. ministat of nir_opt_cse: N Min Max Median Avg Stddev x 9 6.586801 6.718673 6.682875 6.6621411 0.047817119 + 9 6.519098 6.609235 6.552997 6.5605604 0.028879587 Difference at 95.0% confidence -0.101581 +/- 0.0394755 -1.52475% +/- 0.585928% (Student's t, pooled s = 0.0395) Signed-off-by: Rhys Perry Reviewed-by: Tatsuyuki Ishi Part-of: --- src/compiler/nir/nir_instr_set.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index 5f72eff1af6..b421151ab39 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -240,10 +240,8 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr) memcpy(v + 20, &backend_flags, 4); hash = XXH32(v, sizeof(v), hash); - for (unsigned i = 0; i < instr->num_srcs; i++) { - hash = HASH(hash, instr->src[i].src_type); - hash = hash_src(hash, &instr->src[i].src); - } + for (unsigned i = 0; i < instr->num_srcs; i++) + hash *= hash_src(0, &instr->src[i].src); return hash; }