Mesa (main): gallivm: fix non-32 bit popcounts.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 16 23:48:51 UTC 2021


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Nov 26 17:24:15 2020 +1000

gallivm: fix non-32 bit popcounts.

Fixes
OpenCL CTS integer_ops popcount

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12285>

---

 src/gallium/auxiliary/gallivm/lp_bld_nir.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index d9ccc5addbf..981db1fa22f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -591,6 +591,10 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base,
       break;
    case nir_op_bit_count:
       result = lp_build_popcount(get_int_bld(bld_base, false, src_bit_size[0]), src[0]);
+      if (src_bit_size[0] < 32)
+         result = LLVMBuildZExt(builder, result, bld_base->int_bld.vec_type, "");
+      else if (src_bit_size[0] > 32)
+         result = LLVMBuildTrunc(builder, result, bld_base->int_bld.vec_type, "");
       break;
    case nir_op_bitfield_select:
       result = lp_build_xor(&bld_base->uint_bld, src[2], lp_build_and(&bld_base->uint_bld, src[0], lp_build_xor(&bld_base->uint_bld, src[1], src[2])));



More information about the mesa-commit mailing list