[cfe-dev] clang does not use sincos with -O2 but gcc does
Dennis Luehring via cfe-dev
cfe-dev at lists.llvm.org
Thu May 18 08:19:37 PDT 2017
Thank you
so GCCs folding to sincos is semi OK
>reason why <cmath> functions can not marked constexpr :-/
:o/
>I would personally like the base <cmath> functions
>to be wholly ignorant of errno
that would be great
>the errno requirement is a rare case that unfortunately
>affects the optimizability of a large portion of code
im currently doing a test-project and im freaking out
about all these low-level-but-not-optimizable stuff, and
every compiler/platform is more/less ignoring some parts
things getting even "better" when using the microsoft compiler :(
Dennis
Am 18.05.2017 um 17:12 schrieb Halfdan Ingvarsson:
> The answer lies inside of canCombineSinCosLibcall in
> lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:
>
> ....
> // GNU sin/cos functions set errno while sincos does not. Therefore
> // combining sin and cos is only safe if unsafe-fpmath is enabled.
> ....
>
> unsafe-fpmath is enabled with -ffast-math.
>
> I.e. folding to sincos is unlikely to be standard compliant. It's also the
> reason why <cmath> functions can not marked constexpr :-/
>
> IMHO, errno is an anachronism and should never have been included as a part
> of <cmath>. I would personally like the base <cmath> functions to be wholly
> ignorant of errno, and there to be a separate set of <cmath> functions that
> throw the appropriate exceptions for those rare cases where knowledge of
> domain errors is important.
>
> I've yet to come across production code that checks errno in any capacity
> after calling a math function (language support libraries excepted). I feel
> that the errno requirement is a rare case that unfortunately affects the
> optimizability of a large portion of code that could benefit from its
> absence altogether.
>
> - ½
>
> On 18 May 2017 at 10:20, René J.V. Bertin via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
> > On Thursday May 18 2017 14:55:03 Dennis Luehring wrote:
> >
> > >clang DOES use sincos if -ffast-math option is given
> > >gcc use it even without -ffast-math
> >
> > To make matters even more complex: on Mac the situation is the opposite,
> > that is clang always uses a sincos library function provided by Apple.
> >
> > >i don't think its the x87 opcode - because then LLVM would inline it -
> > and not using a call
> >
> > That depends, LLVM cannot know how the sincos() function from libm is
> > implemented.
> >
> > R.
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> >
>
More information about the cfe-dev
mailing list