summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-08-24 23:00:37 -0400
committerAndres Gomez <[email protected]>2018-09-12 00:53:35 +0300
commitad3151a02dc5bd285967307effbafb7d5512201a (patch)
tree6f30f6861f082ec29302f01dc91eb7f8f66d2878 /src/amd
parent7b2e888770ce167468703fccde49c63cd86121f7 (diff)
ac: revert new LLVM 7.0 behavior for fdiv
Cc: 18.2 <[email protected]> Tested-by: Dieter Nützel <[email protected]> (cherry picked from commit a5f35aa742c3f1e2fae6a6c2fb53f92822f0cb70)
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/common/ac_llvm_build.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 54b7e987015..5e4f410a8da 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -555,7 +555,14 @@ ac_build_fdiv(struct ac_llvm_context *ctx,
LLVMValueRef num,
LLVMValueRef den)
{
- LLVMValueRef ret = LLVMBuildFDiv(ctx->builder, num, den, "");
+ /* If we do (num / den), LLVM >= 7.0 does:
+ * return num * v_rcp_f32(den * (fabs(den) > 0x1.0p+96f ? 0x1.0p-32f : 1.0f));
+ *
+ * If we do (num * (1 / den)), LLVM does:
+ * return num * v_rcp_f32(den);
+ */
+ LLVMValueRef rcp = LLVMBuildFDiv(ctx->builder, ctx->f32_1, den, "");
+ LLVMValueRef ret = LLVMBuildFMul(ctx->builder, num, rcp, "");
/* Use v_rcp_f32 instead of precise division. */
if (!LLVMIsConstant(ret))