From 675ef9c0c7d178438f0901e3c13c381828b3c139 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 16 Feb 2017 22:52:53 +0100 Subject: [PATCH] ac/llvm: use min+max instead of AMDGPU.clamp on LLVM 5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It selects v_med3_f32, which has the same rate & size. Reviewed-by: Dave Airlie Reviewed-by: Nicolai Hähnle --- src/amd/common/ac_llvm_build.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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] = { -- 2.30.2