summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2020-03-20 16:35:45 -0400
committerMarge Bot <[email protected]>2020-03-21 22:34:17 +0000
commit303842b2dbf30e7dd1a4cd463e76aecf81adebb8 (patch)
tree453508f310b619ceac90585bad12e4e1427739a2 /src/amd
parent55b0a676fdb538095b8d7c6e93a92d702534df39 (diff)
ac: fix fast division
This stopped working with LLVM 11 and might occasionally have been broken on older LLVM, because the metadata was set on the mul, not on the rcp. Cc: 19.3 20.0 <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4268> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4268>
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/llvm/ac_llvm_build.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index dcbd4efeacf..373eb77b4a0 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -715,12 +715,11 @@ ac_build_fdiv(struct ac_llvm_context *ctx,
*/
LLVMValueRef one = LLVMConstReal(LLVMTypeOf(num), 1.0);
LLVMValueRef rcp = LLVMBuildFDiv(ctx->builder, one, den, "");
- LLVMValueRef ret = LLVMBuildFMul(ctx->builder, num, rcp, "");
-
/* Use v_rcp_f32 instead of precise division. */
- if (!LLVMIsConstant(ret))
- LLVMSetMetadata(ret, ctx->fpmath_md_kind, ctx->fpmath_md_2p5_ulp);
- return ret;
+ if (!LLVMIsConstant(rcp))
+ LLVMSetMetadata(rcp, ctx->fpmath_md_kind, ctx->fpmath_md_2p5_ulp);
+
+ return LLVMBuildFMul(ctx->builder, num, rcp, "");
}
/* See fast_idiv_by_const.h. */