Module: Mesa Branch: master Commit: 8eaf9c61d17370d3f272ca39256de58231c02127 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8eaf9c61d17370d3f272ca39256de58231c02127
Author: Daniel Schürmann <[email protected]> Date: Fri Oct 9 11:54:46 2020 +0200 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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6666> --- src/compiler/nir/nir.h | 4 ++-- src/compiler/nir/nir_opt_vectorize.c | 16 ++++++++-------- src/gallium/auxiliary/nir/nir_to_tgsi.c | 17 +++++++---------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index ad75665a1f0..aa26e43742c 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -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); diff --git a/src/compiler/nir/nir_opt_vectorize.c b/src/compiler/nir/nir_opt_vectorize.c index 077adfcb166..de819035580 100644 --- a/src/compiler/nir/nir_opt_vectorize.c +++ b/src/compiler/nir/nir_opt_vectorize.c @@ -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; } diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 79018fdc21c..51968bd7447 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -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; } _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
