g77/686 -O2 in 19991122 breaks Kahan sum
N8TM@aol.com
N8TM@aol.com
Wed Nov 24 22:07:00 GMT 1999
While ss 19991122 has fixed certain bugs with -O2 on i686, it seems now that
-O2 is violating parentheses. Kahan' s sum formula works accurately at -Os
but not at -O2, as it does in gcc-2.95.2. i.e.
s= 0
y= 0
C
C Kahan Summation: Knuth, D.E. 1981 "The Art of Programmming"
C Addison-Wesley, Reading MA USA vol II 2nd ed (proof p. 572)
do k= 1,n
y= y+(k)*v(k)
t= s+y
y= y-(t-s)
s= t
enddo
no longer produces accurate results. It makes no difference whether
-ffast-math is in effect. If such "optimizations" are to be available, they
should not be a default part of a normal optimization option. It would be
bad enough to have this intentional violation of language standards thrown
together with the fast comparison in -ffast-math. BTW, -ffast-math is still
totally breaking some cases of max() and min().
Tim
tprince@computer.org
More information about the Gcc-bugs
mailing list