summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-10-01 14:57:31 +1000
committerDave Airlie <airlied@redhat.com>2020-10-02 04:17:49 +1000
commit4c70f1ba2fb2ef0aef33d0f7f160ad110b731615 (patch)
treef2d7ed87f1886f22756bd4a4ce5f7aebdf6f74a4
parente8f1cc41db3aab4f2fe3462749f096986effa972 (diff)
gallivm/nir: fix non-32 bit find lsb/msb
fixes piglit cl get-global-id Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6954>
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_nir.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index 612a4ff754e..3ed0dac798a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -573,9 +573,15 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base,
case nir_op_fge32:
result = fcmp32(bld_base, PIPE_FUNC_GEQUAL, src_bit_size[0], src);
break;
- case nir_op_find_lsb:
- result = lp_build_cttz(get_int_bld(bld_base, false, src_bit_size[0]), src[0]);
+ case nir_op_find_lsb: {
+ struct lp_build_context *int_bld = get_int_bld(bld_base, false, src_bit_size[0]);
+ result = lp_build_cttz(int_bld, src[0]);
+ if (src_bit_size[0] < 32)
+ result = LLVMBuildZExt(builder, result, bld_base->uint_bld.vec_type, "");
+ else if (src_bit_size[0] > 32)
+ result = LLVMBuildTrunc(builder, result, bld_base->uint_bld.vec_type, "");
break;
+ }
case nir_op_flog2:
result = lp_build_log2_safe(&bld_base->base, src[0]);
break;
@@ -799,6 +805,10 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base,
struct lp_build_context *uint_bld = get_int_bld(bld_base, true, src_bit_size[0]);
result = lp_build_ctlz(uint_bld, src[0]);
result = lp_build_sub(uint_bld, lp_build_const_int_vec(gallivm, uint_bld->type, src_bit_size[0] - 1), result);
+ if (src_bit_size[0] < 32)
+ result = LLVMBuildZExt(builder, result, bld_base->uint_bld.vec_type, "");
+ else
+ result = LLVMBuildTrunc(builder, result, bld_base->uint_bld.vec_type, "");
break;
}
case nir_op_uge32: