This is the mail archive of the 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]

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

On Thu, Oct 05, 2006 at 07:28:34PM -0700, Steve Kargl wrote:
> 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().

Here's a new patch that removes the inlining of spacing in favor of
a library routine.  It also adds HAVE_LDEXP[F,L] checks to configure.
Regression tested on amd64-*-freebsd.

2006-10-06  Steven G. Kargl  <>

	* 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): Use it.

	PR fortran/15441
	PR fortran/29312
	* iresolve.c (gfc_resolve_rrspacing): Give rrspacing library
	routine hidden precision argument.
	(gfc_resolve_spacing): Give rrspacing library routine hidden
	precision, emin - 1, and tiny(x) arguments.
 	* simplify.c (gfc_simplify_nearest): Remove explicit subnormalization.
	(gfc_simplify_rrspacing): Implement formula from Fortran 95 standard.
 	(gfc_simplify_spacing): Implement formula from Fortran 2003 standard.
 	* trans-intrinsic.c (gfc_intrinsic_map_t) Declare rrspacing and
	spacing via LIBF_FUNCTION
	(prepare_arg_info, call_builtin_clz, gfc_conv_intrinsic_spacing,
	gfc_conv_intrinsic_rrspacing): Remove functions.
	(gfc_conv_intrinsic_function): Remove calls to 
	gfc_conv_intrinsic_spacing and gfc_conv_intrinsic_rrspacing.
	* f95-lang.c (gfc_init_builtin_functions): Remove __builtin_clz,
	__builtin_clzl and __builtin_clzll
2006-10-06  Steven G. Kargl  <>
	PR fortran/15441
	PR fortran/29312
	* m4/spacing.m4: New file.  Use new HAVE_* defines.
	* m4/rrspacing.m4: Ditto.
	* Handle new files.
	* configure: Regenerated.
	* Ditto.
	* Ditto.
	* generated/spacing_r4.c: Generated.
	* generated/spacing_r8.c: Ditto.
	* generated/spacing_r10.c: Ditto.
	* generated/spacing_r16.c: Ditto.
	* generated/rrspacing_r4.c: Ditto.
	* generated/rrspacing_r8.c: Ditto.
	* generated/rrspacing_r10.c: Ditto.
	* generated/rrspacing_r16.c: Ditto.


Attachment: lgfc.diff
Description: Text document

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