[PATCH] Returns NaN for sqrt with negative fp argument

Tim Northover t.p.northover at gmail.com
Wed Jun 11 07:49:00 PDT 2014

> For me it seems more consistent to return the correct value (qNaN) if
> there is no penalty for choosing it.

Consistent with what? There are plenty of precedents for turning
undefined behaviour into "undef". That's pretty much what it's there

I really don't think we should be in the business of papering over
undefined behaviour like that, even (especially!) if it can turn an
obvious failure into a latent one.

> Is there any performance advantage of using the explicitly incorrect 0.0?

There's probably no significant difference between 0.0 and NaN, but
there could well be between either and undef if it allows future
optimisations. If we make any change here, it should be that one.



More information about the llvm-commits mailing list