Floating point performance issue

Vincent Lefevre vincent+gcc@vinc17.org
Tue Dec 20 13:58:00 GMT 2011

On 2011-12-20 14:01:19 +0100, David Brown wrote:
> There are times when you want IEEE-accurate floating point, because you are
> pushing the limits of accuracy, or you want high repeatability.  But
> normally when you use floating point, you are accepting a certain amount of
> inaccuracy.  If your code is going to produce incorrect answers because of
> the way the compiler/cpu rounds calculations, orders your sums, or treats
> denormals and other specials, then I would argue that your code is probably
> wrong - perhaps you should be using decimal types, long doubles, __float128,
> or some sort of multi-precision maths library instead.

I disagree: the operations could be written in an order to avoid some
inaccuracies (such as huge cancellations) or to emulate more precision
(e.g. via Veltkamp's splitting) or to control the rounding (see some
rint() implementation http://sourceware.org/bugzilla/show_bug.cgi?id=602
for instance). On such code, unsafe optimizations could yield problems.

Vincent Lefèvre <vincent@vinc17.net> - 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)

More information about the Gcc-help mailing list