From 18bdc7145982d9188d1141f0dc19467db7cb3b34 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 7 Mar 2023 13:08:36 +0200 Subject: [PATCH] intel/fs: fix nir_opt_peephole_ffma max vec assumption MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit There can be larger vec than vec4. Signed-off-by: Lionel Landwerlin Cc: mesa-stable Reviewed-by: Marcin Ślusarz Part-of: --- src/intel/compiler/brw_nir_opt_peephole_ffma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/intel/compiler/brw_nir_opt_peephole_ffma.c b/src/intel/compiler/brw_nir_opt_peephole_ffma.c index ce8d637..2a39a22 100644 --- a/src/intel/compiler/brw_nir_opt_peephole_ffma.c +++ b/src/intel/compiler/brw_nir_opt_peephole_ffma.c @@ -68,9 +68,9 @@ are_all_uses_fadd(nir_ssa_def *def) static nir_alu_instr * get_mul_for_src(nir_alu_src *src, unsigned num_components, - uint8_t swizzle[4], bool *negate, bool *abs) + uint8_t *swizzle, bool *negate, bool *abs) { - uint8_t swizzle_tmp[4]; + uint8_t swizzle_tmp[NIR_MAX_VEC_COMPONENTS]; assert(src->src.is_ssa && !src->abs && !src->negate); nir_instr *instr = src->src.ssa->parent_instr; @@ -133,7 +133,7 @@ get_mul_for_src(nir_alu_src *src, unsigned num_components, * Expected output swizzle = zyxx * If we reuse swizzle in the loop, then output swizzle would be zyzz. */ - memcpy(swizzle_tmp, swizzle, 4*sizeof(uint8_t)); + memcpy(swizzle_tmp, swizzle, NIR_MAX_VEC_COMPONENTS*sizeof(uint8_t)); for (int i = 0; i < num_components; i++) swizzle[i] = swizzle_tmp[src->swizzle[i]]; @@ -189,10 +189,10 @@ brw_nir_opt_peephole_ffma_instr(nir_builder *b, return false; nir_alu_instr *mul; - uint8_t add_mul_src, swizzle[4]; + uint8_t add_mul_src, swizzle[NIR_MAX_VEC_COMPONENTS]; bool negate, abs; for (add_mul_src = 0; add_mul_src < 2; add_mul_src++) { - for (unsigned i = 0; i < 4; i++) + for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) swizzle[i] = i; negate = false; -- 2.7.4