mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
nir/instr_set: combine XXH32 calls
ministat of nir_opt_cse:
N Min Max Median Avg Stddev
x 9 7.393408 7.490593 7.434056 7.4338972 0.028150325
+ 9 6.724212 6.84511 6.788336 6.7873378 0.034363882
Difference at 95.0% confidence
-0.646559 +/- 0.0313916
-8.69745% +/- 0.407925%
(Student's t, pooled s = 0.0314111)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30145>
This commit is contained in:
parent
159a3edd80
commit
8b328443e3
1 changed files with 33 additions and 30 deletions
|
|
@ -77,15 +77,17 @@ hash_alu_src(uint32_t hash, const nir_alu_src *src, unsigned num_components)
|
|||
static uint32_t
|
||||
hash_alu(uint32_t hash, const nir_alu_instr *instr)
|
||||
{
|
||||
hash = HASH(hash, instr->op);
|
||||
|
||||
/* We explicitly don't hash instr->exact. */
|
||||
uint8_t flags = instr->no_signed_wrap |
|
||||
instr->no_unsigned_wrap << 1;
|
||||
hash = HASH(hash, flags);
|
||||
|
||||
hash = HASH(hash, instr->def.num_components);
|
||||
hash = HASH(hash, instr->def.bit_size);
|
||||
uint8_t v[8];
|
||||
v[0] = flags;
|
||||
v[1] = instr->def.num_components;
|
||||
v[2] = instr->def.bit_size;
|
||||
v[3] = 0;
|
||||
uint32_t op = instr->op;
|
||||
memcpy(v + 4, &op, sizeof(op));
|
||||
hash = XXH32(v, sizeof(v), hash);
|
||||
|
||||
if (nir_op_infos[instr->op].algebraic_properties & NIR_OP_IS_2SRC_COMMUTATIVE) {
|
||||
assert(nir_op_infos[instr->op].num_inputs >= 2);
|
||||
|
|
@ -119,9 +121,12 @@ hash_alu(uint32_t hash, const nir_alu_instr *instr)
|
|||
static uint32_t
|
||||
hash_deref(uint32_t hash, const nir_deref_instr *instr)
|
||||
{
|
||||
hash = HASH(hash, instr->deref_type);
|
||||
hash = HASH(hash, instr->modes);
|
||||
hash = HASH(hash, instr->type);
|
||||
uint32_t v[4];
|
||||
v[0] = instr->deref_type;
|
||||
v[1] = instr->modes;
|
||||
uint64_t type = (uintptr_t)instr->type;
|
||||
memcpy(v + 2, &type, sizeof(type));
|
||||
hash = XXH32(v, sizeof(v), hash);
|
||||
|
||||
if (instr->deref_type == nir_deref_type_var)
|
||||
return HASH(hash, instr->var);
|
||||
|
|
@ -213,8 +218,8 @@ hash_intrinsic(uint32_t hash, const nir_intrinsic_instr *instr)
|
|||
hash = HASH(hash, instr->intrinsic);
|
||||
|
||||
if (info->has_dest) {
|
||||
hash = HASH(hash, instr->def.num_components);
|
||||
hash = HASH(hash, instr->def.bit_size);
|
||||
uint8_t v[4] = { instr->def.num_components, instr->def.bit_size, 0, 0 };
|
||||
hash = XXH32(v, sizeof(v), hash);
|
||||
}
|
||||
|
||||
hash = XXH32(instr->const_index, info->num_indices * sizeof(instr->const_index[0]), hash);
|
||||
|
|
@ -228,31 +233,29 @@ hash_intrinsic(uint32_t hash, const nir_intrinsic_instr *instr)
|
|||
static uint32_t
|
||||
hash_tex(uint32_t hash, const nir_tex_instr *instr)
|
||||
{
|
||||
hash = HASH(hash, instr->op);
|
||||
hash = HASH(hash, instr->num_srcs);
|
||||
uint8_t v[24];
|
||||
v[0] = instr->op;
|
||||
v[1] = instr->num_srcs;
|
||||
v[2] = instr->coord_components | (instr->sampler_dim << 4);
|
||||
uint8_t flags = instr->is_array | (instr->is_shadow << 1) | (instr->is_new_style_shadow << 2) |
|
||||
(instr->is_sparse << 3) | (instr->component << 4) | (instr->texture_non_uniform << 6) |
|
||||
(instr->sampler_non_uniform << 7);
|
||||
v[3] = flags;
|
||||
STATIC_ASSERT(sizeof(instr->tg4_offsets) == 8);
|
||||
memcpy(v + 4, instr->tg4_offsets, 8);
|
||||
uint32_t texture_index = instr->texture_index;
|
||||
uint32_t sampler_index = instr->sampler_index;
|
||||
uint32_t backend_flags = instr->backend_flags;
|
||||
memcpy(v + 12, &texture_index, 4);
|
||||
memcpy(v + 16, &sampler_index, 4);
|
||||
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);
|
||||
}
|
||||
|
||||
hash = HASH(hash, instr->coord_components);
|
||||
hash = HASH(hash, instr->sampler_dim);
|
||||
hash = HASH(hash, instr->is_array);
|
||||
hash = HASH(hash, instr->is_shadow);
|
||||
hash = HASH(hash, instr->is_new_style_shadow);
|
||||
hash = HASH(hash, instr->is_sparse);
|
||||
unsigned component = instr->component;
|
||||
hash = HASH(hash, component);
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
for (unsigned j = 0; j < 2; ++j)
|
||||
hash = HASH(hash, instr->tg4_offsets[i][j]);
|
||||
hash = HASH(hash, instr->texture_index);
|
||||
hash = HASH(hash, instr->sampler_index);
|
||||
hash = HASH(hash, instr->texture_non_uniform);
|
||||
hash = HASH(hash, instr->sampler_non_uniform);
|
||||
hash = HASH(hash, instr->backend_flags);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue