This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: alternative to -ffloat-store on x86?
- To: Dave Love <d dot love at dl dot ac dot uk>
- Subject: Re: alternative to -ffloat-store on x86?
- From: "Theodore C. Belding" <streak at umich dot edu>
- Date: Tue, 24 Nov 1998 09:58:01 -0500 (EST)
- cc: egcs at cygnus dot com
Hi-
Thanks for the pointer!
My program is in C++; do you have a code snippet that would work in C++,
or would
__setfpucw ((_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE);
work in gcc/g++ as well as g77?
-Ted
--
Ted Belding Ted.Belding@umich.edu
University of Michigan Program for the Study of Complex Systems
http://www-personal.umich.edu/~streak/
On 24 Nov 1998, Dave Love wrote:
> >>>>> "TCB" == Theodore C Belding <Ted.Belding@umich.edu> writes:
>
> TCB> I need to force strict IEEE floating-point compliance in a
> TCB> program that I'm compiling with egcs 1.1 for x86, so that
> TCB> floating-point results are exactly the same as on other
> TCB> platforms.
>
> I can't guarantee exactly that, at least not for Fortran in general.
>
> TCB> Is -ffloat-store still the best way to do this, or is there a
> TCB> better alternative?
>
> I don't think it's in the 1.1 version, but the development version of
> the g77 manual has this; I think I have recipes that should work on
> other x86 systems.
>
> Floating point precision
> ------------------------
>
> If your program depends on exact IEEE 754 floating point handling it
> may help on some systems--specifically x86 or m68k hardware--to use the
> `-ffloat-store' option or to reset the precision flag on the floating
> point unit *Note Optimize Options::.
>
> However, it might be better simply to put the FPU into double
> precision mode and not take the performance hit of `-ffloat-store'. On
> x86 and m68k GNU systems you can do this with a technique similar to
> that for turning on floating point exceptions *Note Floating-point
> Exception Handling::. The control word could be set to double
> precision by replacing the `__setfpucw' call with one like this:
> __setfpucw ((_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE);
> (It is not clear whether this has any effect on the operation of the
> GNU maths library, but we have no evidence of it causing trouble.)
>
> TCB> I apologize if this has been discussed before; I wasn't able to find
> TCB> anything in a web search of the mailing list archives.
>
> Probably well disguised under a random subject...
>