From: Timothy Arceri Date: Tue, 6 Feb 2018 03:34:55 +0000 (+1100) Subject: ac: add 64bit bitCount support X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=19f9839f0b94146227076f45dbbc62077d64e7a9;p=mesa.git ac: add 64bit bitCount support v2: use LLVMBuildTrunc() Reviewed-by: Marek Olšák --- diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 550c12d249c..b842641383c 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1917,7 +1917,12 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) result = ac_build_intrinsic(&ctx->ac, "llvm.bitreverse.i32", ctx->ac.i32, src, 1, AC_FUNC_ATTR_READNONE); break; case nir_op_bit_count: - result = ac_build_intrinsic(&ctx->ac, "llvm.ctpop.i32", ctx->ac.i32, src, 1, AC_FUNC_ATTR_READNONE); + if (get_elem_bits(&ctx->ac, LLVMTypeOf(src[0])) == 32) + result = ac_build_intrinsic(&ctx->ac, "llvm.ctpop.i32", ctx->ac.i32, src, 1, AC_FUNC_ATTR_READNONE); + else { + result = ac_build_intrinsic(&ctx->ac, "llvm.ctpop.i64", ctx->ac.i64, src, 1, AC_FUNC_ATTR_READNONE); + result = LLVMBuildTrunc(ctx->ac.builder, result, ctx->ac.i32, ""); + } break; case nir_op_vec2: case nir_op_vec3: