Calculating cosinus/sinus

jacob navia jacob@jacob.remcomp.fr
Sat May 11 09:37:00 GMT 2013


Le 11/05/13 11:20, Oleg Endo a écrit :
> Hi,
>
> This question is not appropriate for this mailing list.
> Please take any further discussions to the gcc-help mailing list.
>
> On Sat, 2013-05-11 at 11:15 +0200, jacob navia wrote:
>> Hi
>>
>> When caculating the cos/sinus, gcc generates a call to a complicated
>> routine that takes several thousand instructions to execute.
>>
>> Suppose the value is stored in some XMM register, say xmm0 and the
>> result should be in another xmm register, say xmm1.
>>
>> Why it doesn't generate:
>>
>>       movsd    %xmm0,(%rsp)
>>       fldl     (%rsp)
>>       fsin
>>       fstpl    (%rsp)
>>       movsd    (%rsp),%xmm1
>>
>> My compiler system (lcc-win) is generating that when optimizations are
>> ON. Maybe there are some flags in gcc that I am missing?
> These optimizations are usually turned on with -ffast-math.
> You also have to make sure to select the appropriate CPU or architecture
> type to enable the usage of certain instructions.
>
> For more information see:
> http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html
>
> Cheers,
> Oleg
Sorry but I DID try:

gcc -ffast-math -S -O3 -finline-functions  tsin.c

Will generate a call to sin() and NOT the assembly above.

AndI DID look at the options page.



More information about the Gcc mailing list