[PATCH] Returns NaN for sqrt with negative fp argument

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


Hi James,

On 11 June 2014 08:14, James Molloy <james.molloy at arm.com> wrote:
> Could I please weigh in here? I’d like the behaviour to be NaN too, but for a different reason.

I think that might be an orthogonal issue. What you want is an
IEEE-compliant sqrt, except that it doesn't necessarily set errno.
LLVM already has this concept: it's represented by a call to @sqrt
with the "readnone" attribute. Clang produces it with -fno-math-errno
(via SemaDecl.cpp:10290 ultimately)

>From Jiangning:
> I think it is not OK, because undef means an undefined value, and for well-defined program, this undef shouldn't affect semantic

@llvm.sqrt seems to be for true -ffast-math situations, where calling
with a negative number is user error; the program is not well-defined
if that happens in -ffast-math. Which is why I still think undef is
the right choice.

Cheers.

Tim.




More information about the llvm-commits mailing list