radeonsi: use ac_build_bit_count instead of opencoding it

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11486>
This commit is contained in:
Marek Olšák 2021-05-30 20:32:25 -04:00
parent 70b5a5cbbf
commit 3cde2f96f9
2 changed files with 2 additions and 7 deletions

View File

@ -679,8 +679,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx)
LLVMValueRef accepted_threadmask = ac_get_i1_sgpr_mask(&ctx->ac, accepted);
/* Count the number of active threads by doing bitcount(accepted). */
LLVMValueRef num_prims_accepted = ac_build_intrinsic(
&ctx->ac, "llvm.ctpop.i64", ctx->ac.i64, &accepted_threadmask, 1, AC_FUNC_ATTR_READNONE);
LLVMValueRef num_prims_accepted = ac_build_bit_count(&ctx->ac, accepted_threadmask);
num_prims_accepted = LLVMBuildTrunc(builder, num_prims_accepted, ctx->ac.i32, "");
LLVMValueRef start;

View File

@ -226,11 +226,7 @@ static LLVMValueRef si_scale_alpha_by_sample_mask(struct si_shader_context *ctx,
/* alpha = alpha * popcount(coverage) / SI_NUM_SMOOTH_AA_SAMPLES */
coverage = LLVMGetParam(ctx->main_fn, samplemask_param);
coverage = ac_to_integer(&ctx->ac, coverage);
coverage = ac_build_intrinsic(&ctx->ac, "llvm.ctpop.i32", ctx->ac.i32, &coverage, 1,
AC_FUNC_ATTR_READNONE);
coverage = ac_build_bit_count(&ctx->ac, ac_to_integer(&ctx->ac, coverage));
coverage = LLVMBuildUIToFP(ctx->ac.builder, coverage, ctx->ac.f32, "");
coverage = LLVMBuildFMul(ctx->ac.builder, coverage,