diff options
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_llvm_build.c | 26 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_build.h | 3 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 9045df7a0d9..ab93aa25d24 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -244,6 +244,32 @@ ac_build_optimization_barrier(struct ac_llvm_context *ctx, } LLVMValueRef +ac_build_ballot(struct ac_llvm_context *ctx, + LLVMValueRef value) +{ + LLVMValueRef args[3] = { + value, + ctx->i32_0, + LLVMConstInt(ctx->i32, LLVMIntNE, 0) + }; + + /* We currently have no other way to prevent LLVM from lifting the icmp + * calls to a dominating basic block. + */ + ac_build_optimization_barrier(ctx, &args[0]); + + if (LLVMTypeOf(args[0]) != ctx->i32) + args[0] = LLVMBuildBitCast(ctx->builder, args[0], ctx->i32, ""); + + return ac_build_intrinsic(ctx, + "llvm.amdgcn.icmp.i32", + ctx->i64, args, 3, + AC_FUNC_ATTR_NOUNWIND | + AC_FUNC_ATTR_READNONE | + AC_FUNC_ATTR_CONVERGENT); +} + +LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMValueRef *values, unsigned value_count, diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 4466e2f3057..8369e59f28c 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -77,6 +77,9 @@ void ac_build_type_name_for_intr(LLVMTypeRef type, char *buf, unsigned bufsize); void ac_build_optimization_barrier(struct ac_llvm_context *ctx, LLVMValueRef *pvgpr); + +LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value); + LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMValueRef *values, |