An x86 bug in egcs 1.0.2?
Byeong-ryeol Kim
jinbo21@soback.kornet.nm.kr
Wed Apr 15 07:11:00 GMT 1998
On Mon, 13 Apr 1998, H.J. Lu wrote:
> Can someone please tell me if it is an egcs 1.0.2 bug?
....
> Did you see my example (posted in March egcs-bugs)
>
> No problem under glibc-2.1 Trouble with glibc-2.0.6 & glibc-2.0.7pre2
> The problen is not numerical precision (Jim Wilson), but in-lining asm.
>
> gcc -o tst -O2 -mpentiumpro tst.c Works
> gcc -o tst -O2 -mpentium tst.c Fails
> gcc -o tst -O2 -m486 tst.c "
>
> Regards,
>
> Roger Brown
>
....
> int main ()
> {
> printf(" Gamma(1.2): %16.9e %16.9e\n", gamma(1.2), exp(lgamma(1.2)));
> }
....
I tested above code on my rh5.0 system(kernel-2.1.96pre1,
glibc-2.0.7-6+wcsmbs-patch, egcs-1.0.2+latest-i386.md-patch+libio.patch,
binutils-2.9.0.2). If necessary, I use ASUS P/I-P55T2P4 with
AMD-PR2/MMX-200(stepping 1), 64M EDO RAM, 512K pipelined burst cache RAM.
There were problems according to optimization level.
In short, using '-m386', '-m486', '-mpentium' with any optimization level
yields erroneous results. Using '-mpentiumpro' and any '-O?' except '-O'
yileds seems to yields accurate results.
results:
1) no otimization
$ gcc -o test -m486 test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
$ gcc -o test -mpentium test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
$ gcc -o test -mpentiumpro test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
2) various optimization
2-1) '-m386' & '-m486'
$ /usr/bin/gcc -O -o test -m386 test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
$ /usr/bin/gcc -O3 -o test test.c -lm
$ ./test
Gamma(1.2): 1.234298459e-55 9.181687424e-01
$ /usr/bin/gcc -O2 -o test test.c -lm
$ ./test
Gamma(1.2): 1.234298459e-55 9.181687424e-01
$ /usr/bin/gcc -O9 -o test -m386 test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
$ /usr/bin/gcc -O -o test -m486 test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
$ /usr/bin/gcc -O2 -o test -m486 test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
$ /usr/bin/gcc -O3 -o test -m486 test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
$ /usr/bin/gcc -O6 -o test -m486 test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
$ /usr/bin/gcc -O9 -o test -m486 test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
2-2) '-mpentium'
$ /usr/bin/gcc -O -o test -mcpu=pentium -march=pentium test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
$ /usr/bin/gcc -O2 -o test -mcpu=pentium -march=pentium test.c -lm
$ ./test
Gamma(1.2): 1.234298459e-55 9.181687424e-01
$ /usr/bin/gcc -O3 -o test -mcpu=pentium -march=pentium test.c -lm
$ ./test
Gamma(1.2): 1.234298459e-55 9.181687424e-01
$ /usr/bin/gcc -O6 -o test -mcpu=pentium -march=pentium test.c -lm
$ ./test
Gamma(1.2): 1.234298459e-55 9.181687424e-01
$ /usr/bin/gcc -O9 -o test -mcpu=pentium -march=pentium test.c -lm
$ ./test
Gamma(1.2): 1.234298459e-55 9.181687424e-01
2-3) '-mpentiumpro'
$ /usr/bin/gcc -O -o test -mcpu=pentiumpro -march=pentiumpro test.c -lm
$ ./test
Gamma(1.2): 6.235220524e+00 9.181687424e-01
$ /usr/bin/gcc -O2 -o test -mcpu=pentiumpro -march=pentiumpro test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
$ /usr/bin/gcc -O3 -o test -mcpu=pentiumpro -march=pentiumpro test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
$ /usr/bin/gcc -O4 -o test -mcpu=pentiumpro -march=pentiumpro test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
$ /usr/bin/gcc -O6 -o test -mcpu=pentiumpro -march=pentiumpro test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
$ /usr/bin/gcc -O9 -o test -mcpu=pentiumpro -march=pentiumpro test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
$ /usr/bin/gcc -O2 -o test -mcpu=pentiumpro -march=pentiumpro test.c -lm
$ ./test
Gamma(1.2): 9.181687424e-01 9.181687424e-01
"Where there is a will, there is a way." jinbo21@soback.kornet.nm.kr
kbeyl@kids.kotel.co.kr
For the future of you and me! hitel: jinbo21
More information about the Gcc
mailing list