This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -f[no-]finite-math-only
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Daniel Franke <franke dot daniel at gmail dot com>
- Cc: gcc at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Thu, 2 Jul 2009 13:26:16 +0200
- Subject: Re: -f[no-]finite-math-only
- References: <200907021202.52013.franke.daniel@gmail.com>
On Thu, Jul 2, 2009 at 12:02 PM, Daniel Franke<franke.daniel@gmail.com> wrote:
>
> Dear all,
>
> some Fortran77 code I inherited gives wrong results if compiled
> with '-ffast-math', especially with '-ffinite-math-only' enabled
> ('-ffast-math -fno-finite-math-only' seems to work).
>
> As '-ffinite-math-only' does "Allow optimizations for floating-point
> arithmetic that assume that arguments and results are not NaNs or +-Infs", it
> is to assume that the code uses either or both. If so, it's very likely that
> this was not intended by the original author.
>
> Any pointers on how to track down these issues in ~25kloc of Fortran77 to
> double check what's going on?
The code is likely using isinf/isnan intrinsics (if such exist) or
comparisons like x != x which check for NaN. Those are optimized
away with -ffinite-math-only.
Richard.
> Thanks
>
>
> ? ? ? ?Daniel
>
>
> P.S. Not using '-ffast-math' would of course be an option, but knowing that
> there might be something fishy going on with NaN/Inf does not improve the
> confidence in the application's results ...
>