------- Comment #3 from fxcoudert at gcc dot gnu dot org  2009-06-15 18:32 
-------
This is not darwin-specific, I also see it happening on x86_64-linux.

And what's more, the output changes between -m32 and -m64.

$ cat u.f90
integer(8), parameter :: l = z'5fe6eb3be0000000'
integer, parameter :: ni = 3
integer :: i, j, n
integer(8) :: k
real(8) :: a, b, e, m, s
equivalence (b, k)
a = 1.0d0
e = epsilon(1.0)/2.0d0**4
m = 0.0d0
s = 0.0d0
n = 0
do
  n = n + 1
  b = a
  k = l - ishft(k, -1_8)
  do i = 1, ni
    b = b*(1.5-(0.5*a)*b*b)
  end do
  b = b + b*(0.5-(0.5*a)*b*b)
!   b = 1.0d0/sqrt(a)
  m = max(m, abs(a*b*b - 1.0d0))
  s = s + abs(a*b*b - 1.0d0)
  a = a + e
  if (a == 2.0d0) exit
end do
print *, n, m/epsilon(a), s/(n*epsilon(a))
end

$ gfortran -m64 -O3 u.f90 && time ./a.out                                     
   134217728   2.0000000000000000       0.36966567113995552     
./a.out  3.05s user 0.00s system 100% cpu 3.049 total

$ gfortran -m32 -O3 u.f90 && time ./a.out                                     
   134217728  9.76562500000000000E-004  1.82069155926001258E-004
./a.out  6.80s user 0.00s system 99% cpu 6.854 total

$ gfortran -m32 -O3 u.f90 -ffast-math && time ./a.out
   134217728  1.46484375000000000E-003  2.97074087939108722E-004
./a.out  6.74s user 0.00s system 99% cpu 6.743 total

$ gfortran -m64 -O3 u.f90 -ffast-math && time ./a.out
   134217728   3.0000000000000000       0.59681034088134766     
./a.out  3.18s user 0.00s system 99% cpu 3.178 total


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|i686-apple-darwin9          |
   GCC host triplet|i686-apple-darwin9          |
 GCC target triplet|i686-apple-darwin9          |i686
      Known to fail|                            |4.4.0 4.5.0
   Last reconfirmed|2008-05-15 09:06:21         |2009-06-15 18:32:39
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36241

Reply via email to