[PATCH] D43765: [InstSimplify] loosen FMF for sqrt(X) * sqrt(X) --> X

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 5 10:50:42 PST 2018


spatel added a comment.

In https://reviews.llvm.org/D43765#1027330, @spatel wrote:

> In https://reviews.llvm.org/D43765#1027302, @arsenm wrote:
>
> > In https://reviews.llvm.org/D43765#1027289, @scanon wrote:
> >
> > > IIRC `Intrinsic::sqrt` is undef for negative inputs (unlike the `sqrt` libcall), so we don't need `FMF.noNaNs` to license this transformation.
> >
> >
> > Although IMO if we're fixing all of the math in LLVM I would like to fix this. At least do something like ctlz/cttz for whether negative is undef
>
>
> Sqrt was fixed:
>  https://reviews.llvm.org/D28797


Also, note that we convert sqrt and other libcalls to the LLVM intrinsics when possible in clang:
https://reviews.llvm.org/D39204 (and follow-up commits listed there)
...so we don't have to muddy the code looking for sqrt libcall patterns too. If errno can be set by a libcall, then no amount of FMF should override that; if errno can't be set by the libcall, it should have been converted to the LLVM intrinsic.


https://reviews.llvm.org/D43765





More information about the llvm-commits mailing list