http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50032

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-10 
09:03:53 UTC ---
GCC changes

  floatvar = (float) cos ((double) floatvar));

to

  floatvar = cosf (floatvar);

if your math library implementation has a slower cosf than cos it's
definitely broken ;)

Then GCC goes along and optimizes

  x = cosf (ang)
  y = sinf (ang)

to

  sincosf (ang, &x, &y)

because again that's not slower (well ... unless you have a broken libm).

Thus, please report to Ubuntu that their sincosf is slower than sincos.

And no, the CPU definitely can do float math faster than double math.

You can disable the optimization via -fno-builtin-sincos

Btw,

            float ang = i*j*2*M_PI/N;

is performed in double arithmetic as well, as M_PI is a double constant.
You'll likely get faster code with using

            float ang = i*j*2*((float)M_PI)/N;

btw, you didn't specify if you are using 32bit or 64bit code.

Reply via email to