[PATCH] Returns NaN for sqrt with negative fp argument

Jiangning Liu liujiangning1 at gmail.com
Tue Jun 10 03:17:04 PDT 2014


Tim,

> Or vice versa, why is fp zero a more reasonable implementation than NaN
> for
> > this case?
>
> I'd say the best implementation would be undef (possibly even
> reporting a warning, though that's strictly QoI and probably better as
> a sanitizer anyway). I'm not sure why 0.0 is there at the moment
> though.
>

I think now I understand this a little bit. Following LLVM IR spec, when
using -ffast-math, -menable-no-nans are -menable-unsafe-fp-math enabled,
and this sounds reasonable to retain defined/stable/safe behavior, so we
can't return NaN, then 0.0 is a choice.

Thanks,
-Jiangning


>
> Cheers.
>
> Tim.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140610/cc11a8c1/attachment.html>


More information about the llvm-commits mailing list