This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: FWD: FLOATING-POINT CONSISTENCY, -FFLOAT-STORE, AND X86
- To: Geert Bosch <bosch at gnat dot com>
- Subject: Re: FWD: FLOATING-POINT CONSISTENCY, -FFLOAT-STORE, AND X86
- From: Stephen L Moshier <moshier at mediaone dot net>
- Date: Tue, 15 Dec 1998 09:43:14 -0500 (EST)
- cc: "Harvey J. Stein" <hjstein at bfr dot co dot il>, "egcs at cygnus dot com" <egcs at cygnus dot com>, "tprince at cat dot e-mail dot com" <tprince at cat dot e-mail dot com>
- Reply-To: moshier at mediaone dot net
On Tue, 15 Dec 1998, Geert Bosch wrote:
> and a compiler evaluating B + (A - B) as (B + A) - B or even as A
> is seriously broken for numerical stuff.
Associative law "optimizations" were rooted out of gcc years ago.
But I do know of at least two commercial dsp compilers, based on gcc-2.3
or earlier, that might have this problem.
The reasons for the compiler deciding to write something out to
memory, or to not write it out, are many and mysterious. I have
analyzed only one test case in which all 8 fpu registers actually got
used up and something had to be spilled. That program really cratered
the computer and it is enshrined in c-torture.
If you declare an item to be long double precision in your source
program, then it better stay long double, or else please do post a test
case right away! If you don't have long double, then maybe long double
is what you should be asking for.
If you want to guarantee a value will be written out to memory,
you can simply declare the memory variable to be "volatile."
Then the compiler cannot continue to ignore you. The reason
this works, and must work on all compilers that optimize, is that
you would not be able to write hardware device drivers if "volatile"
did not work. Software people seem to find this solution unappealing.
I do not understand why.