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 39a938ecf4 doing the same).

Fixes: 4eb0475b5a ("gallivm/nir: add fsum support")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12066>
This commit is contained in:
Roland Scheidegger 2021-07-26 16:55:10 +02:00 committed by Marge Bot
parent 6691a48bcc
commit cac5711d43

View file

@ -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]);