This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/6914: -O2 and -O give different results for the same valid FP code
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- To: "Michael Veksler" <VEKSLER at il dot ibm dot com>
- Cc: tprince at computer dot org,gcc-gnats at gcc dot gnu dot org,gcc-prs at gcc dot gnu dot org,gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Jun 2002 18:16:21 +0200
- Subject: Re: c++/6914: -O2 and -O give different results for the same valid FP code
At 17:49 03.06.2002, Michael Veksler wrote:
Tim Prince wrote:
+ Among the remedies available would be
+ a) set 53-bit rounding mode
+ b) choose -msse2, for appropriate targets
After rereading the gcc manual, I found "-ffloat-store" which is the best
remedy. It is described in:
http://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Optimize-Options.html#Optimize%20Options
It says "For most programs, the excess precision does only good". This
statement is wrong. It is unbearable to have a perfectly valid
code behave differently with -O2 and -O0 on the same platform. The default
should be changed to -ffloat-store. Of course, when passing
-funsafe-math-optimizations, gcc may also set -fno-float-store.
If the decision will be to keep the current behavior, documentation should
be updated. It should be more clear that -float-store is critical for IEEE
conformance on targets like x86. Also, the bugs section should contain
this as a known bug (and bug it is -- gcc does not conform to the IEEE
standard on x86).
Because GCC does not mess with the settings of the CPU, which is certainly
_not_ GCC's job. Checkout glibc's documentation and look at stuff like
fpu_control.h and fenv.h.
Franz.