This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: code optimizations and numerical research
- From: Brian Gough <bjg at network-theory dot co dot uk>
- To: p at dirac dot org (Peter Jay Salzman)
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 17 May 2005 20:37:57 +0100
- Subject: Re: code optimizations and numerical research
- References: <20050516144507.GB16966@dirac.org>
Peter Jay Salzman writes:
> The man page claims that "-ffast-math" may produce wrong results for
> programs that depend on "an exact implementation of IEEE or ISO
> rules/specifications for math functions."
>
> What exactly does this vague sentence mean?
The main problem is that Infs and NaNs are manipulated as finite
numbers in optimisations and comparisons with -ffast-math. e.g. you
can find that x-x==0 for x=Inf and other similar oddities. Some
programs use non-standard idioms like if(x!=x) for checking if x is
NaN.
--
Brian Gough
(GNU Scientific Library Maintainer)
p.s. don't forget to profile your program.
Network Theory Ltd,
Publishing "An Introduction to GCC" --- http://www.network-theory.co.uk/gcc/