From: Marek Olšák Date: Fri, 20 Mar 2020 20:35:45 +0000 (-0400) Subject: ac: fix fast division X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=303842b2dbf30e7dd1a4cd463e76aecf81adebb8;p=mesa.git 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: --- 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. */