Mesa (main): llvmpipe: fix nir dot products (fsum op)

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 27 01:23:42 UTC 2021


Module: Mesa
Branch: main
Commit: cac5711d433fa1519be101ad3dae1e1d53c9a55a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cac5711d433fa1519be101ad3dae1e1d53c9a55a

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Mon Jul 26 16:55:10 2021 +0200

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 <erik.faye-lund at collabora.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12066>

---

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



More information about the mesa-commit mailing list