This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Optimization and floating point
- To: "'Tony_LELIEVRE at pechiney dot com'" <Tony_LELIEVRE at pechiney dot com>, gcc-help at gcc dot gnu dot org
- Subject: RE: Optimization and floating point
- From: David Korn <dkorn at pixelpower dot com>
- Date: Thu, 22 Mar 2001 16:56:57 -0000
>-----Original Message-----
>From: Tony_LELIEVRE@pechiney.com [mailto:Tony_LELIEVRE@pechiney.com]
>Sent: 22 March 2001 16:24
>I use a finite element code written in C++ and I want to
>compile it on a pentium III processor (I am using Cygwin under
>NT). The problem is that when I optimize the compilation (just
>with -O), one of
>the calculus give an infinite result (NaN). I do not think it
>is a problem of my code since I've used it for one year on SGI
>and it was OK.
>
>In order to try to understand the problem, I have tested the
>little program paranoia.c (cf.
>http://www.netlib.org/paranoia/) and it turns out that a lot
>of problems appear when I compile with -O, but
>the result is good when I compile without optimization. I have
>also tried the Watcom compiler, and it gives good results...
These two options might be relevant:
------snip!------
`-ffloat-store'
Do not store floating point variables in registers, and inhibit
other options that might change whether a floating point value is
taken from a register or memory.
This option prevents undesirable excess precision on machines such
as the 68000 where the floating registers (of the 68881) keep more
precision than a `double' is supposed to have. Similarly for the
x86 architecture. For most programs, the excess precision does
only good, but a few programs rely on the precise definition of
IEEE floating point. Use `-ffloat-store' for such programs, after
modifying them to store all pertinent intermediate computations
into variables.
`-ffast-math'
This option allows GCC to violate some ANSI or IEEE rules and/or
specifications in the interest of optimizing code for speed. For
example, it allows the compiler to assume arguments to the `sqrt'
function are non-negative numbers and that no floating-point values
are NaNs.
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 ANSI rules/specifications for math
functions.
------snip!------
-ffast-math seems the most likely candidate, although according to
the docs it shouldn't be enabled by -O. But just in case there's a bug
and it *is* being enabled, trying again with '-O -fno-fast-math' would
be the first thing worth trying. If that doesn't help I'm afraid I
don't have any particularly bright ideas.
DaveK
--
All your base are belong to us!
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************