From cac5711d433fa1519be101ad3dae1e1d53c9a55a Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 26 Jul 2021 16:55:10 +0200 Subject: [PATCH] llvmpipe: fix nir dot products (fsum op) When the dot product uses a source which can be optimized to a scalar, after a bunch of nir optimization steps the source to fsum will be a scalar with a x replicate swizzle. Hence nir_src_num_components is just 1 and the fsum was just a no-op which is not correct. Arguably this could be optimized a bit better, but just determine the number of addends by using nir_op_infos instead (the operand fetch was fixed already by 39a938ecf41b doing the same). Fixes: 4eb0475b5a00 ("gallivm/nir: add fsum support") Reviewed-by: Erik Faye-Lund Reviewed-by: Brian Paul Reviewed-by: Dave Airlie Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 8db40661231..3669e6e6fc1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1021,7 +1021,7 @@ static void visit_alu(struct lp_build_nir_context *bld_base, const nir_alu_instr result[i] = cast_type(bld_base, src[i], nir_op_infos[instr->op].input_types[i], src_bit_size[i]); } } else if (instr->op == nir_op_fsum4 || instr->op == nir_op_fsum3 || instr->op == nir_op_fsum2) { - for (unsigned c = 0; c < nir_src_num_components(instr->src[0].src); c++) { + for (unsigned c = 0; c < nir_op_infos[instr->op].input_sizes[0]; c++) { LLVMValueRef temp_chan = LLVMBuildExtractValue(gallivm->builder, src[0], c, ""); temp_chan = cast_type(bld_base, temp_chan, nir_op_infos[instr->op].input_types[0], src_bit_size[0]);