From 303842b2dbf30e7dd1a4cd463e76aecf81adebb8 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 20 Mar 2020 16:35:45 -0400 Subject: 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 Reviewed-by: Samuel Pitoiset Tested-by: Marge Bot Part-of: --- src/amd/llvm/ac_llvm_build.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/amd') 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. */ -- cgit v1.2.3