Commit 8eaf9c61 authored by Daniel Schürmann's avatar Daniel Schürmann Committed by Marge Bot
Browse files

nir/opt_vectorize: don't hash filtered instructions



This patch also changes nir_opt_vectorize_cb to
use only one instruction as parameter.
Reviewed-by: Connor Abbott's avatarConnor Abbott <cwabbott0@gmail.com>
Part-of: <mesa/mesa!6666>
parent 23b28855
......@@ -4978,8 +4978,8 @@ bool nir_lower_undef_to_zero(nir_shader *shader);
bool nir_opt_uniform_atomics(nir_shader *shader);
typedef bool (*nir_opt_vectorize_cb)(const nir_instr *a, const nir_instr *b,
void *data);
typedef bool (*nir_opt_vectorize_cb)(const nir_instr *instr, void *data);
bool nir_opt_vectorize(nir_shader *shader, nir_opt_vectorize_cb filter,
void *data);
......
......@@ -159,8 +159,7 @@ instr_can_rewrite(nir_instr *instr, bool vectorize_16bit)
*/
static nir_instr *
instr_try_combine(struct nir_shader *nir, nir_instr *instr1, nir_instr *instr2,
nir_opt_vectorize_cb filter, void *data)
instr_try_combine(struct nir_shader *nir, nir_instr *instr1, nir_instr *instr2)
{
assert(instr1->type == nir_instr_type_alu);
assert(instr2->type == nir_instr_type_alu);
......@@ -180,9 +179,6 @@ instr_try_combine(struct nir_shader *nir, nir_instr *instr1, nir_instr *instr2,
assert(alu1->dest.dest.ssa.bit_size == 16);
}
if (filter && !filter(&alu1->instr, &alu2->instr, data))
return NULL;
nir_builder b;
nir_builder_init(&b, nir_cf_node_get_function(&instr1->block->cf_node));
b.cursor = nir_after_instr(instr1);
......@@ -333,14 +329,18 @@ vec_instr_set_add_or_rewrite(struct nir_shader *nir, struct set *instr_set,
if (!instr_can_rewrite(instr, nir->options->vectorize_vec2_16bit))
return false;
if (filter && !filter(instr, data))
return false;
struct set_entry *entry = _mesa_set_search(instr_set, instr);
if (entry) {
nir_instr *old_instr = (nir_instr *) entry->key;
_mesa_set_remove(instr_set, entry);
nir_instr *new_instr = instr_try_combine(nir, old_instr, instr,
filter, data);
nir_instr *new_instr = instr_try_combine(nir, old_instr, instr);
if (new_instr) {
if (instr_can_rewrite(new_instr, nir->options->vectorize_vec2_16bit))
if (instr_can_rewrite(new_instr, nir->options->vectorize_vec2_16bit) &&
(!filter || filter(instr, data)))
_mesa_set_add(instr_set, new_instr);
return true;
}
......
......@@ -2188,23 +2188,20 @@ type_size(const struct glsl_type *type, bool bindless)
* can handle for 64-bit values in TGSI.
*/
static bool
ntt_should_vectorize_instr(const nir_instr *in_a, const nir_instr *in_b,
void *data)
ntt_should_vectorize_instr(const nir_instr *instr, void *data)
{
if (in_a->type != nir_instr_type_alu)
if (instr->type != nir_instr_type_alu)
return false;
nir_alu_instr *a = nir_instr_as_alu(in_a);
nir_alu_instr *b = nir_instr_as_alu(in_b);
nir_alu_instr *alu = nir_instr_as_alu(instr);
unsigned a_num_components = a->dest.dest.ssa.num_components;
unsigned b_num_components = b->dest.dest.ssa.num_components;
unsigned num_components = alu->dest.dest.ssa.num_components;
int src_bit_size = nir_src_bit_size(a->src[0].src);
int dst_bit_size = nir_dest_bit_size(a->dest.dest);
int src_bit_size = nir_src_bit_size(alu->src[0].src);
int dst_bit_size = nir_dest_bit_size(alu->dest.dest);
if (src_bit_size == 64 || dst_bit_size == 64) {
if (a_num_components + b_num_components > 2)
if (num_components > 1)
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment