This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[PATCH] fortran/15441,29312 -- Fix subnormal numbers, spacing, rrspacing.


The attached patch has been bootstrapped and regression tested
on amd64-*-freebsd.  There are no regressions with this patch.

The patch fixes 2 PR's that are related, and it also introduces
a new preprocsor token GFC_MPFR_TOO_OLD to aid in testing gfortran
with older and newer versions of mpfr.

The primary problems are that spacing() and rrspacing() did not
handle the special case 0. and did not handle subnormal numbers
well.  To fix rrspacing, I have removed the inlining of this
intrinsic procedure in favor of library routine.  Before anyone
complains "fast and wrong" is probably not as good as "slower
and correct".

Dominique posted a program in PR 29312 that gfortran now compiles
and executes correctly.

There is one caveat.  The rrspacing library routines use ldexp[f,l].
If anyone reports a problem with these C99 functions I'll introduce
pow().

The gcc/fortran/ChangeLog entry:

2006-10-05  Steven G. Kargl  <kargl@gcc.gnu.org>

	* gfortran.h: Define GFC_MPFR_TOO_OLD via MPFR version info.
	* arith.c (arctangent, gfc_check_real_range): Use it.
	* simplify.c (gfc_simplify_atan2, gfc_simplify_exponent,
	gfc_simplify_log, gfc_simplify_nearest): Ditto.
 
	PR fortran/15441
	PR fortran/29312
	* iresolve.c (gfc_resolve_rrspacing): Generate hidden arg for precision.
	* trans-intrinsic.c (gfc_intrinsic_map_t): Add LIBF_FUNCTION for RRSPACING.
	(call_builtin_clz, gfc_conv_intrinsic_rrspacing): Delete.
	(gfc_conv_intrinsic_function): Don't call gfc_conv_intrinsic_rrspacing.
	* f95-lang.c (gfc_init_builtin_functions): Remove builtin functions
	__builtin_clz, __builtin_clzl, and __builtin_clzll.
	* simplify.c (gfc_simplify_nearest): Remove subnormalization.
	(gfc_simplify_rrspacing): Fix rrspacing(0.).  Implement the Fortran 95
	formula of |x * 2**(-e)| * 2**p to handle subnormal numbers.
	(gfc_simplify_spacing): Fix spacing(0.).  Implement the Fortran 2003
	formula of b**max(e - p, emin - 1) to handle subnormal numbers.

The libgfortran ChangeLog:

2006-10-05  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/15441
	PR fortran/29312
	* m4/rrspacing.m4: New file.
	* Makefile.am: Handle rrspacing.m4
	* Makefile.in: Regenerated.
-- 
Steve

Attachment: rrspacing.diff
Description: Text document


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