This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR32239 Use builtin_powi


Janne Blomqvist wrote:
On 6/27/07, Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
On Wed, Jun 27, 2007 at 11:23:19AM +0200, Tobias Burnus wrote:
> 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.
>


Looks like an issue with subnormal numbers.  If 1.4012985E-45 isn't
the smallest subnorml number, it's awefully close.  y/2. has underflowed
to zero.

The algorithms implemented by _gfortran_pow vs. builtin_powi (builtin_powi in the PR) basically do the same thing, I don't think we can say one is better than the other.

Perhaps the testcase should be changed to test something like

abs(x-y) < ulp * spacing(max(abs(x),abs(y)))

instead of the somewhat ad hoc test used now?

After a brief discussion on irc, committed to trunk along with the testsuite fix.



-- Janne Blomqvist


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]