Hi,
I'm interested in gcc 4.0.0 because I believe it's supposed to generate
the fsincos instruction on x86 when appropriate.
I have the following code sample which I use to generate two random
Gaussian numbers, for which I think fsincos should probably be generated
by the compiler,
typedef double realv;
complex<realv> ComplexGaussRandom(realv s2, MTRand& Random)
{
realv B = 2.0 * pi * Random.rand();
realv R = sqrt( -s2 * log(1- Random.rand53()));
return R * complex<realv>(cos(B), sin(B));
}
If I compile with
$ ~/usr/bin/gcc-4.0.0 -S Com_Code.cc -ffast-math -O2
the relevant generated code section is
#APP
fldln2; fxch; fyl2x
#NO_APP
fmulp %st, %st(2)
fxch %st(1)
#APP
fsqrt
#NO_APP
fld %st(1)
#APP
fsin
#NO_APP
fxch %st(2)
#APP
fcos
#NO_APP
fxch %st(2)
movl 8(%ebp), %eax
fmul %st(1), %st
fxch %st(1)
fmulp %st, %st(2)
fstpl 8(%eax)
fstpl (%eax)
addl $12, %esp
popl %ebx
popl %esi
popl %edi
popl %ebp
ret $4
So after generating R, a separate fsin and fcos seem to be generated. Am I
missing an option or something?
Thanks,
Patrick
$ ~/usr/bin/gcc-4.0.0 -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.0/configure --program-suffix=-4.0.0
--prefix=/home/mitran/usr
Thread model: posix
gcc version 4.0.0