[Patch, fortran] PR32239 Use builtin_powi

Tobias Burnus burnus@net-b.de
Wed Jun 27 09:23:00 GMT 2007


Tobias Burnus wrote:
> Ok for the trunk. I assume you have regtested it; in any case it builds
> and some limited testing shows no problems.
>   
I bootstrapped and regtested it (x86-64/Linux). For -m32 everything is
ok, but for -m64 it fails for:

gfortran.fortran-torture/execute/intrinsic_fraction_exponent.f90's
test_4 (third call).

Instead of:
 test_4; x =  1.4012985E-45  y=  0.5000000      z=        -148
 test_4; y=  1.4012985E-45  |x-y|=  0.000000     |x*1e-6|=   0.000000
the result is:
 test_4; x =  1.4012985E-45  y=  0.5000000      z=        -148
 test_4; y=   0.000000      |x-y|= 1.4012985E-45 |x*1e-6|=   0.000000
and the latter fails because |x-y| > |x*1e-6|.

The dump looks ok:
-      y = (y * 2.0e+0) * _gfortran_pow_r4_i4 (2.0e+0, z + -1);
+      y = (y * 2.0e+0) * __builtin_powif (2.0e+0, z + -1);
     }
   else
     {
-      y = (y / 2.0e+0) * _gfortran_pow_r4_i4 (2.0e+0, z + 1);
+      y = (y / 2.0e+0) * __builtin_powif (2.0e+0, z + 1);

Thus the builtin_powi gives a different result; I don't see ad hoc
whether both results are ok or whether one implementation has a bug.

Tobias

PS: For completeness the excerpt from the source:

subroutine test_4(x)
real*4 x,y
integer z
y = fraction (x)
z = exponent(x)
if (z .gt. 0) then
  y = (y * 2.) * (2. ** (z - 1))
else
  y = (y / 2.) * (2. ** (z + 1))
end if
if (abs (x - y) .gt. abs(x * 1e-6)) call abort()
end



More information about the Fortran mailing list