[PATCH] Returns NaN for sqrt with negative fp argument

Tim Northover t.p.northover at gmail.com
Tue Jun 10 04:01:28 PDT 2014


> 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.

I think we probably *could* return a NaN, other phases would just be
perfectly entitled to assume we hadn't. Which makes it a not
particularly useful thing to return.

0.0 probably isn't too bad either though; the advantage of "undef" is
that it looks dodgy when scanning through IR so might make tracking
down bugs easier.

Cheers.

Tim.



More information about the llvm-commits mailing list