[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 05:55:03 PDT 2017


>It may have something to do with the fact that sincos()
>is a GNU extension to the standard math lib?

clang DOES use sincos if -ffast-math option is given
gcc use it even without -ffast-math

so the questions are:
-is gcc wrong in using sincos without -ffast-math
-is clang wrong in seeing sincos as to evil (only accepting it with -ffast-math)

is it because cos and sin can produce different (FPU)NaN/Exception-Results so
the flow is different when using the combined sincos?

>Also, I hope it doesn't expand to a call to the x87 FPU instruction,
>but IIRC that one is actually slower than 2 calls
>to modern sin() and cos() implementations :)

i don't think its the x87 opcode - because then LLVM would inline it - and not using a call

Am 18.05.2017 um 13:58 schrieb René J.V. Bertin:

> On Thursday May 18 2017 10:09:14 Dennis Luehring via cfe-dev wrote:
>
> >why do clang needs the -ffast-math option to use the sincos function here?
> >gcc uses the sincos function without -ffast-math
>
> It may have something to do with the fact that sincos() is a GNU extension to the standard math lib?
>
> Also, I hope it doesn't expand to a call to the x87 FPU instruction, but IIRC that one is actually slower than 2 calls to modern sin() and cos() implementations :)
>
> R.





More information about the cfe-dev mailing list