From: Marek Olšák Date: Mon, 30 Dec 2019 19:08:09 +0000 (-0500) Subject: ac: add 128-bit bitcount X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1c44480538ac9bc6d5900a0704cbc447afc735f9;p=mesa.git ac: add 128-bit bitcount Reviewed-by: Pierre-Eric Pelloux-Prayer --- diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index a66272873f0..b62b81999d3 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -85,6 +85,7 @@ ac_llvm_context_init(struct ac_llvm_context *ctx, ctx->i16 = LLVMIntTypeInContext(ctx->context, 16); ctx->i32 = LLVMIntTypeInContext(ctx->context, 32); ctx->i64 = LLVMIntTypeInContext(ctx->context, 64); + ctx->i128 = LLVMIntTypeInContext(ctx->context, 128); ctx->intptr = ctx->i32; ctx->f16 = LLVMHalfTypeInContext(ctx->context); ctx->f32 = LLVMFloatTypeInContext(ctx->context); @@ -108,6 +109,8 @@ ac_llvm_context_init(struct ac_llvm_context *ctx, ctx->i32_1 = LLVMConstInt(ctx->i32, 1, false); ctx->i64_0 = LLVMConstInt(ctx->i64, 0, false); ctx->i64_1 = LLVMConstInt(ctx->i64, 1, false); + ctx->i128_0 = LLVMConstInt(ctx->i128, 0, false); + ctx->i128_1 = LLVMConstInt(ctx->i128, 1, false); ctx->f16_0 = LLVMConstReal(ctx->f16, 0.0); ctx->f16_1 = LLVMConstReal(ctx->f16, 1.0); ctx->f32_0 = LLVMConstReal(ctx->f32, 0.0); @@ -2817,6 +2820,12 @@ LLVMValueRef ac_build_bit_count(struct ac_llvm_context *ctx, LLVMValueRef src0) bitsize = ac_get_elem_bits(ctx, LLVMTypeOf(src0)); switch (bitsize) { + case 128: + result = ac_build_intrinsic(ctx, "llvm.ctpop.i128", ctx->i128, + (LLVMValueRef []) { src0 }, 1, + AC_FUNC_ATTR_READNONE); + result = LLVMBuildTrunc(ctx->builder, result, ctx->i32, ""); + break; case 64: result = ac_build_intrinsic(ctx, "llvm.ctpop.i64", ctx->i64, (LLVMValueRef []) { src0 }, 1, diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h index 8672977bd67..af774ab092f 100644 --- a/src/amd/llvm/ac_llvm_build.h +++ b/src/amd/llvm/ac_llvm_build.h @@ -73,6 +73,7 @@ struct ac_llvm_context { LLVMTypeRef i16; LLVMTypeRef i32; LLVMTypeRef i64; + LLVMTypeRef i128; LLVMTypeRef intptr; LLVMTypeRef f16; LLVMTypeRef f32; @@ -96,6 +97,8 @@ struct ac_llvm_context { LLVMValueRef i32_1; LLVMValueRef i64_0; LLVMValueRef i64_1; + LLVMValueRef i128_0; + LLVMValueRef i128_1; LLVMValueRef f16_0; LLVMValueRef f16_1; LLVMValueRef f32_0;