[LLVMdev] Optimization of sqrt() with invalid argument
Hal Finkel
hfinkel at anl.gov
Sat Sep 27 18:33:51 PDT 2014
----- Original Message -----
> From: "Joerg Sonnenberger" <joerg at britannica.bec.de>
> To: llvmdev at cs.uiuc.edu
> Sent: Friday, September 26, 2014 5:14:54 PM
> Subject: Re: [LLVMdev] Optimization of sqrt() with invalid argument
>
> On Fri, Sep 26, 2014 at 01:52:19PM -0500, Bill Schmidt wrote:
> > At the least, we should constant-fold to NaN for the non fast-math
> > sqrt
> > calls...there's no point in going through the libcall overhead when
> > we
> > know the answer in advance. I can prepare a patch for that if
> > everyone
> > agrees.
>
> The crux is that sqrt(-1) can set errno, can't it?
-ffast-math implies -fno-math-errno, but otherwise the default is target specific. On Linux, math calls can set errno by default, for example. On Darwin, they don't. On systems that can set errno, we indeed cannot constant fold the result unless we can prove the errno modification is not observable in a well-defined way. However, because we set different attributes on the functions depending on whether errno can be set or not, I think we already handle this correctly.
-Hal
>
> Joerg
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-dev
mailing list