-ffast-math compiler option

Armitage

Banned
Feb 23, 2001
8,086
0
0
Anybody use it? I just turned it on on a whim and picked up about 7% (on repeated runs).

Among other things, this turns on -funsafe-math-optimizations
From the man page:

-funsafe-math-optimizations
Allow optimizations for floating-point arithmetic that (a) assume that arguments and results are valid and (b) may violate IEEE or ANSI standards. When used at link-time, it may include libraries or startup files that change the default FPU control word or other similar optimizations.

This option should never be turned on by any -O option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ISO rules/specifications for math functions.

So the engineer in me is saying Bad Idea, and I'll probably stick with that. But a quick look at the results doesn't show any significant difference and 7% is 7%, right? So I'm wondering if anybody has any better insight into what this option means.

FWIW, this is GCC 3.3.5, Linux on dual opterons, 64 bit
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Here's an example of a difference in the results. The value is a range between two objects in Km

32.6364004527575 With -ffast-math
32.6364004529829 Without --fast-math

2.25e-10 Km = 225 nanometers
Not to bad considering the errors in the models I'm using are at least on the order of meters to 10s of meters.