[PATCH] D28508: [NVPTX] Lower to sqrt.approx and rsqrt.approx under more circumstances.
Hal Finkel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 13 17:33:02 PST 2017
hfinkel added a comment.
In https://reviews.llvm.org/D28508#643613, @jlebar wrote:
>
...
> But specifically for sqrt (AFAIK) I need to rely on some behavior that's not quite kosher according to the langref. Specifically, I need to transform llvm.nvvm.sqrt.f into
>
> s = llvm.sqrt(arg)
> select(arg >= -0.0, s, NaN)
>
>
> The langref says that llvm.sqrt is undefined behavior if you call it with a negative value, but @arsenm, @mehdi_amini, and I think it should say that it *returns undef* if passed a negative value. arsenm looked at the blame and the language has been unchanged since llvm.sqrt was added. His and @mehdi_amini's GPU backends already assume the "returns undef" semantics, and I have code in flight for XLA to do the same. One of them also did a quick audit and concluded none of our current optimizations use the "undefined behavior" behavior.
>
> Mehdi pointed me at a larger patch to fix up this and other math intrinsics which I now can't find (sorry), but maybe we can make this smaller change in parallel?
>
> WDYT?
Sounds reasonable to me.
https://reviews.llvm.org/D28508
More information about the llvm-commits
mailing list