Mesa (master): ac/llvm: implement 16-bit and 64-bit fpow correctly
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Mar 3 20:17:18 UTC 2021
Module: Mesa
Branch: master
Commit: 46ce67a3310220e346382760a07269224b8d74fb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=46ce67a3310220e346382760a07269224b8d74fb
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Feb 12 01:05:19 2021 -0500
ac/llvm: implement 16-bit and 64-bit fpow correctly
LLVM converts to 32 bits and back for llvm.pow, so we can't use it.
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9395>
---
src/amd/llvm/ac_nir_to_llvm.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index a70eb0a64b0..50542687966 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -843,6 +843,15 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
result = ac_build_frexp_mant(&ctx->ac, src[0], instr->dest.dest.ssa.bit_size);
break;
case nir_op_fpow:
+ if (instr->dest.dest.ssa.bit_size != 32) {
+ /* 16 and 64 bits */
+ result = emit_intrin_1f_param(&ctx->ac, "llvm.log2",
+ ac_to_float_type(&ctx->ac, def_type), src[0]);
+ result = LLVMBuildFMul(ctx->ac.builder, result, ac_to_float(&ctx->ac, src[1]), "");
+ result = emit_intrin_1f_param(&ctx->ac, "llvm.exp2",
+ ac_to_float_type(&ctx->ac, def_type), result);
+ break;
+ }
result = emit_intrin_2f_param(&ctx->ac, "llvm.pow", ac_to_float_type(&ctx->ac, def_type),
src[0], src[1]);
break;
More information about the mesa-commit
mailing list