intel arithmetic
Jon Wilkening
wilkenin@math.lbl.gov
Wed Jun 7 15:23:00 GMT 2000
Hello, I'm not sure if this is something that can be fixed in gcc,
or if it is Intel's problem. I think the problem is that registers
with extra precision are being used. It would be better (if it is
possible) to use non-extended precision registers except for variables
declared long double. I read some intel web pages which seemed to imply
that there was some choice in how the registers behaved. Here is the
code:
wilkenin:~/test$ cat cutoff.c
#include <stdio.h>
#include <stdlib.h>
double f() {
return 3.0e-17;
}
int main() {
double sum = 2 + f();
if (sum == 2 + f())
printf("good\n");
else
printf("bad\n");
}
wilkenin:~/test$ gcc cutoff.c
wilkenin:~/test$ a.out
bad
wilkenin:~/test$ gcc -ffloat-store cutoff.c
wilkenin:~/test$ a.out
bad
wilkenin:~/test$ gcc -O2 cutoff.c
wilkenin:~/test$ a.out
bad
wilkenin:~/test$ gcc --version
2.95.2
it was run under redhat-6.2 on an intel pentium III dual processor
machine. (The same code with the same version of gcc on a sun ultrasparc
produces the result "good".) It would save me a lot of headache to
be able to count on floating point values not changing between an
assignment and a later use.
Thanks for your time,
Jon Wilkening
More information about the Gcc-bugs
mailing list