From a0cc0b3a154dfc4370c6eea4271d8a80c6616abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 12 Feb 2021 01:06:18 -0500 Subject: [PATCH] ac/llvm: open code fpow on LLVM 12 using fmul.legacy A quick look at the asm shows that this enables source modifiers (neg, abs) for v_mul_legacy_f32. Totals from affected shaders: SGPRS: 110104 -> 110400 (0.27 %) VGPRS: 57632 -> 57636 (0.01 %) Spilled SGPRs: 66 -> 63 (-4.55 %) Spilled VGPRs: 0 -> 0 (0.00 %) Private memory VGPRs: 0 -> 0 (0.00 %) Scratch size: 0 -> 0 (0.00 %) dwords per thread Code Size: 3290412 -> 3283068 (-0.22 %) bytes Max Waves: 32141 -> 32141 (0.00 %) Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/amd/llvm/ac_nir_to_llvm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index a3e84029909..789557a3252 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -852,6 +852,17 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) ac_to_float_type(&ctx->ac, def_type), result); break; } + if (LLVM_VERSION_MAJOR >= 12) { + result = emit_intrin_1f_param(&ctx->ac, "llvm.log2", + ac_to_float_type(&ctx->ac, def_type), src[0]); + result = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.fmul.legacy", ctx->ac.f32, + (LLVMValueRef[]){result, ac_to_float(&ctx->ac, src[1])}, + 2, AC_FUNC_ATTR_READNONE); + result = emit_intrin_1f_param(&ctx->ac, "llvm.exp2", + ac_to_float_type(&ctx->ac, def_type), result); + break; + } + /* Older LLVM doesn't have fmul.legacy. */ result = emit_intrin_2f_param(&ctx->ac, "llvm.pow", ac_to_float_type(&ctx->ac, def_type), src[0], src[1]); break;