------- Comment #5 from dominiq at lps dot ens dot fr  2009-06-16 20:30 -------
I have forgotten this one!

> 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.

This is probably related to the extra precision for some floating-point
computations (disabled by default on darwin and I refuse to learn what to do to
change it!-).

> The code is invalid Fortran, so gfortran is not required to give
> any sensible output.

You know that it is not relevant for this pr!-( would the following make you
happier?)

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 = transfer(b,k)
  k = l - ishft(k, -1_8)
  b = transfer(k,b)
  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

The timings are:

[ibook-dhum] f90/bug% gfc -O3 pr36241_db.f90
[ibook-dhum] f90/bug% time a.out
   134217728   2.0000000000000000       0.36966567113995552     
7.832u 0.010s 0:07.85 99.8%     0+0k 0+0io 0pf+0w
[ibook-dhum] f90/bug% gfc -m64 -O3 pr36241_db.f90
[ibook-dhum] f90/bug% time a.out
   134217728   2.0000000000000000       0.36966567113995552     
3.327u 0.011s 0:03.35 99.4%     0+0k 0+0io 0pf+0w


-- 


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

Reply via email to