[PATCH] D71706: [SimplifyLibCalls] require fast-math-flags for pow(X, -0.5) transforms
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 07:23:10 PST 2019
spatel created this revision.
spatel added reviewers: efriedma, scanon, takahiro.miyoshi, evandro.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.
As discussed in PR44330:
https://bugs.llvm.org/show_bug.cgi?id=44330
...the transform from pow(X, -0.5) libcall/intrinsic to reciprocal square root can result in small deviations from the expected result due to differences in the pow() implementation and/or the extra rounding step from the division.
This patch proposes to allow that difference with either the 'approximate functions' or 'reassociate' FMF:
http://llvm.org/docs/LangRef.html#fast-math-flags
In practice, this likely means that the code is compiled with all of 'fast' (-ffast-math), but I have preserved the existing specializations for -0.0/-INF that enable generating safe code if those special values are allowed simultaneously with allowing approximation/reassociation.
The question about whether a similar restriction is needed for the non-reciprocal case -- pow(X, 0.5) -- is deferred. That transform is allowed without FMF currently, and this patch does not change that behavior.
https://reviews.llvm.org/D71706
Files:
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/pow-sqrt.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71706.234716.patch
Type: text/x-patch
Size: 4545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191219/a71412db/attachment.bin>
More information about the llvm-commits
mailing list