[PATCH] Returns NaN for sqrt with negative fp argument
t.p.northover at gmail.com
Wed Jun 11 00:48:20 PDT 2014
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)
> 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.
More information about the llvm-commits