Mesa (main): radeonsi: use ac_build_bit_count instead of opencoding it

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jun 20 05:43:00 UTC 2021


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun May 30 20:32:25 2021 -0400

radeonsi: use ac_build_bit_count instead of opencoding it

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11486>

---

 src/gallium/drivers/radeonsi/si_compute_prim_discard.c | 3 +--
 src/gallium/drivers/radeonsi/si_shader_llvm_ps.c       | 6 +-----
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_compute_prim_discard.c b/src/gallium/drivers/radeonsi/si_compute_prim_discard.c
index ccc153af052..c830a857f66 100644
--- a/src/gallium/drivers/radeonsi/si_compute_prim_discard.c
+++ b/src/gallium/drivers/radeonsi/si_compute_prim_discard.c
@@ -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;
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c
index fdf03e17792..c5b58b9a593 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c
@@ -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,



More information about the mesa-commit mailing list