Hi there,
I recently noticed an odd behaviour of gcc. I searched the archives, but
I didn't find anything that really looks like this.
I am currently writing software that must be as numerically stable as
possible. Now the problem is that on Linux-Machines with gcc-2.95.3 and
gcc-2.95.4 (I didn't have other versions to check) using the switch -O2
results in inaccuracies (i.e. a double variable never becomes 0) whilst
-O1 is still alright.
At first I thought I might be using the switches in a wrong way, but
when I checked on a FreeBSD system (gcc-2.95.3) with the exactly same
program and the same switches it worked fine. I also tried switches like
-fno-fast-math and such, but none seemed to solve the problem.
Afterwards I checked with gcc-3.2.1, and everything worked fine with -O2.
Maybe I am missing something about using the correct switches, but I
think it is very odd that gcc on BSD and gcc on Linux show this
different a behaviour. I'd really appreciate if anyone could elighten me
on this issue.
If you're testing to see whether x87 operations are carried out in 53-bit
precision mode, why not say so? No, there's no switch to pass to linux
run-time libraries to change precision mode, but you could use the asm()
functions. WIth gcc-3.2.1, you do have switches to select x87, SSE, or SSE2
code generation, so you can control precision of intermediate operations that
way. If you've truly come across something which isn't in the archives, you
certainly haven't bothered to explain it.