This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/50032] Bad optimization with sin/cos
- From: "fbafelipe at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 12 Aug 2011 17:07:47 +0000
- Subject: [Bug c/50032] Bad optimization with sin/cos
- Auto-submitted: auto-generated
- References: <bug-50032-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50032
--- Comment #3 from Felipe <fbafelipe at gmail dot com> 2011-08-12 17:07:47 UTC ---
(In reply to comment #2)
> > if your math library implementation has a slower cosf than cos it's
> > definitely broken ;)
>
> So it is at least for fedora (see
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=5997
> http://sourceware.org/bugzilla/show_bug.cgi?id=5781
> https://bugzilla.redhat.com/show_bug.cgi?id=521190 and pr34128).
>
> I suspect it is for most (all?) linux libraries (I am not in position to check
> it, but the above pointer will allow anyone interested to see by
> her/himself;-).
Tested in Arch Linux and it has the same problem.
(In reply to comment #1)
> You can disable the optimization via -fno-builtin-sincos
This flag didn't solve the problem (compiling with O1/O2/O3 is still slower
than O0).
> 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;
>
I am aware of that, but the code was just a minimalist working example.
> btw, you didn't specify if you are using 32bit or 64bit code.
It is 64bits.
Some bug reports for this performance issue date from 2008, so it seems we
won't see that fixed any time soon.