Bug#572746: libm: sinf/cosf performance is awful on amd64
On 2010-03-17 19:31:16 +0100, Jerome Vizcaino wrote:
> I do not complain about the sin/cos performance but only on the
> float variants.
OK. I haven't looked at the code, but if sinf() simply calls sin(),
this is suboptimal and there would be room for performance boost
without sacrifying accuracy.
For large arguments, it would always be slower if you care about
not too bad accuracy. If you don't care because "any value between
-1 and 1 is OK", then you could write a wrapper with:
return fabsf(x) < some_bound ? sinf(x) : 0;
> Using -ffast-math gives a nice performance boost but leads to bad
> results (in our cases which may be different from the simple given
> example) so it's not really a workaround.
Yes, that's the problem with optimizations that change the semantics
(in the same way, users can complain about the 32-bit implementation
of trigonometric functions). Note that there are other compiler
options that allow a finer grain control of these optimizations.
You might want to look at them (e.g. man gcc).
Vincent Lefèvre <email@example.com> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)