summaryrefslogtreecommitdiffstats
path: root/src/amd/common
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2018-02-06 14:38:57 +1100
committerTimothy Arceri <[email protected]>2018-02-09 09:42:59 +1100
commit12a2350e6d3b974dec74280543cf5cac22720358 (patch)
treeceeb4df75d0eb7e32ee648afbf64d08b72acab69 /src/amd/common
parenta9f6b392c7647747ca8e8e776f8af800d77d67c1 (diff)
ac: add 64bit support to ac_find_lsb()
v2: use LLVMBuildTrunc() Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/amd/common')
-rw-r--r--src/amd/common/ac_llvm_build.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 902dae048c6..f3d4effbd05 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -2001,6 +2001,20 @@ LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx,
LLVMTypeRef dst_type,
LLVMValueRef src0)
{
+ unsigned src0_bitsize = ac_get_elem_bits(ctx, LLVMTypeOf(src0));
+ const char *intrin_name;
+ LLVMTypeRef type;
+ LLVMValueRef zero;
+ if (src0_bitsize == 64) {
+ intrin_name = "llvm.cttz.i64";
+ type = ctx->i64;
+ zero = ctx->i64_0;
+ } else {
+ intrin_name = "llvm.cttz.i32";
+ type = ctx->i32;
+ zero = ctx->i32_0;
+ }
+
LLVMValueRef params[2] = {
src0,
@@ -2016,15 +2030,19 @@ LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx,
LLVMConstInt(ctx->i1, 1, false),
};
- LLVMValueRef lsb = ac_build_intrinsic(ctx, "llvm.cttz.i32", ctx->i32,
+ LLVMValueRef lsb = ac_build_intrinsic(ctx, intrin_name, type,
params, 2,
AC_FUNC_ATTR_READNONE);
+ if (src0_bitsize == 64) {
+ lsb = LLVMBuildTrunc(ctx->builder, lsb, ctx->i32, "");
+ }
+
/* TODO: We need an intrinsic to skip this conditional. */
/* Check for zero: */
return LLVMBuildSelect(ctx->builder, LLVMBuildICmp(ctx->builder,
LLVMIntEQ, src0,
- ctx->i32_0, ""),
+ zero, ""),
LLVMConstInt(ctx->i32, -1, 0), lsb, "");
}