summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-02-16 22:52:53 +0100
committerMarek Olšák <[email protected]>2017-02-18 02:58:43 +0100
commit675ef9c0c7d178438f0901e3c13c381828b3c139 (patch)
tree3568b848824a2a6e0f0c7c1a685f288d46339430
parent660b55e6d9aa704022476a50e264e56ecaa3fc2d (diff)
ac/llvm: use min+max instead of AMDGPU.clamp on LLVM 5.0
It selects v_med3_f32, which has the same rate & size. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r--src/amd/common/ac_llvm_build.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 351ff88306e..2f25b1400e8 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -817,6 +817,23 @@ ac_emit_umsb(struct ac_llvm_context *ctx,
LLVMValueRef ac_emit_clamp(struct ac_llvm_context *ctx, LLVMValueRef value)
{
+ if (HAVE_LLVM >= 0x0500) {
+ LLVMValueRef max[2] = {
+ value,
+ LLVMConstReal(ctx->f32, 0),
+ };
+ LLVMValueRef min[2] = {
+ LLVMConstReal(ctx->f32, 1),
+ };
+
+ min[1] = ac_emit_llvm_intrinsic(ctx, "llvm.maxnum.f32",
+ ctx->f32, max, 2,
+ AC_FUNC_ATTR_READNONE);
+ return ac_emit_llvm_intrinsic(ctx, "llvm.minnum.f32",
+ ctx->f32, min, 2,
+ AC_FUNC_ATTR_READNONE);
+ }
+
const char *intr = HAVE_LLVM >= 0x0308 ? "llvm.AMDGPU.clamp." :
"llvm.AMDIL.clamp.";
LLVMValueRef args[3] = {