[Mesa-dev] [PATCH 24/38] ac/nir: make ac_find_lsb work on all bit sizes
Rhys Perry
pendingchaos02 at gmail.com
Fri Dec 7 17:22:17 UTC 2018
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
---
src/amd/common/ac_llvm_build.c | 31 +++++--------------------------
1 file changed, 5 insertions(+), 26 deletions(-)
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 6266058b77..754ceda89b 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -2752,29 +2752,10 @@ LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx,
LLVMValueRef src0)
{
unsigned src0_bitsize = ac_get_elem_bits(ctx, LLVMTypeOf(src0));
- const char *intrin_name;
- LLVMTypeRef type;
- LLVMValueRef zero;
-
- switch (src0_bitsize) {
- case 64:
- intrin_name = "llvm.cttz.i64";
- type = ctx->i64;
- zero = ctx->i64_0;
- break;
- case 32:
- intrin_name = "llvm.cttz.i32";
- type = ctx->i32;
- zero = ctx->i32_0;
- break;
- case 16:
- intrin_name = "llvm.cttz.i16";
- type = ctx->i16;
- zero = ctx->i16_0;
- break;
- default:
- unreachable(!"invalid bitsize");
- }
+ char intrin_name[64];
+ LLVMTypeRef type = ac_int_of_size(ctx, src0_bitsize);
+ LLVMValueRef zero = ac_get_zero(ctx, type);
+ snprintf(intrin_name, sizeof(intrin_name), "llvm.cttz.i%d", src0_bitsize);
LLVMValueRef params[2] = {
src0,
@@ -2795,9 +2776,7 @@ LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx,
params, 2,
AC_FUNC_ATTR_READNONE);
- if (src0_bitsize == 64) {
- lsb = LLVMBuildTrunc(ctx->builder, lsb, ctx->i32, "");
- }
+ lsb = ac_build_ui_cast(ctx, lsb, ctx->i32);
/* TODO: We need an intrinsic to skip this conditional. */
/* Check for zero: */
--
2.19.2
More information about the mesa-dev
mailing list