This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
* Re: What is acceptable for -ffast-math? (Was: associative law incombine)
- To: Linus Torvalds <torvalds at transmeta dot com>
- Subject: * Re: What is acceptable for -ffast-math? (Was: associative law incombine)
- From: Stephen L Moshier <moshier at mediaone dot net>
- Date: Sun, 29 Jul 2001 15:14:19 -0400 (EDT)
- cc: tprince at computer dot org, gcc at gcc dot gnu dot org
- Reply-To: moshier at moshier dot ne dot mediaone dot net
> Why not make this easier for the user:
> - default to non-IEEE, but "reasonably safe".
The default GCC behavior is not to allow any optimization
that could change the value of an expression. That rule is easy
for users to understand and surely it is a good rule to keep.
Floating point arithmetic, IEEE or otherwise, does not obey the
associative or distributive laws. To pretend otherwise, without
paying close attention, quickly leads to unexpected numerical
failures. Currently the default is to prohibit associative law
"optimizations" of floating-point expressions, and it ought to stay
that way.
> - make "-ffast-math" mean exactly that: fast.
Historically fast-math has allowed some transformations that could
lose a bit of precision but not, for example, transformations that
could destroy all precision through cancellation error. The addition
of one or more switch levels beyond fast-math retains a
"reasonably-safe speed" level and introduces a level of "break-neck
speed" that may be hazardous to your health.
> - "-mieee":
Associative law optimizations must ordinarily be disallowed even if
not IEEE. The IEEE compliance switch implies further special features
like exception flags and numbers that are Not A Number.