[PATCH] Returns NaN for sqrt with negative fp argument

James Molloy James.Molloy at arm.com
Wed Jun 11 01:00:37 PDT 2014


Hi Tim,

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

Lovely, thanks! I didn't know about that. A quick test proves that call produces the expected fsqrt intrinsic. Now I just need a small pass to emit it with a fallback.

Cheers,

James

> -----Original Message-----
> From: Tim Northover [mailto:t.p.northover at gmail.com]
> Sent: 11 June 2014 08:48
> To: James Molloy
> Cc: Jiangning Liu; llvm-commits
> Subject: Re: [PATCH] Returns NaN for sqrt with negative fp argument
>
> 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.


-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No:  2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No:  2548782




More information about the llvm-commits mailing list