Module: Mesa
Branch: staging/20.0
Commit: 4c2f8b3dd6a2560b6b7b40be685ae728a2c3784f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c2f8b3dd6a2560b6b7b40be685ae728a2c3784f

Author: Marek Olšák <[email protected]>
Date:   Fri Mar 20 16:35:45 2020 -0400

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>
(cherry picked from commit 303842b2dbf30e7dd1a4cd463e76aecf81adebb8)

---

 .pick_status.json            | 2 +-
 src/amd/llvm/ac_llvm_build.c | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index d5d0d216378..2466e1e097c 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -868,7 +868,7 @@
         "description": "ac: fix fast division",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index a1a9a453e4e..6532c57a234 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. */

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to