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/gfortran] Fix handling of subnormal numbers


The attached patch fixes a gaff I made in confusing the
Fortran 95 model numbers and the machine representable
numbers with respect to how mpfr handles subnormal numbers.
Now, that I have everyone confused with the number of
times I've used "number" in the few number of sentences
consider

  program nearest0
    real x
    x = nearest(0., 1.)
    if (x .eq. 0.) call abort
    if (x .ge. tiny(x)) call abort
  end program nearest0

On systems that support subnormal number, the above 
program executes without calling abort, which is the
expected behavior.  If I use -fdump-parse-tree, I see

      ASSIGN x 2.802597e-45
      IF (= x 0)
        CALL _gfortran_abort ()
      ENDIF
      IF (>= x 1.175494e-38)
        CALL _gfortran_abort ()
      ENDIF

which is again what I expect to see.  

Bootstrapped and regression tested on amd64-*-freebsd.
I fixed the 1 regression, which allows Paul B to say
"I told you so" to me :-)


2005-04-13  Steven G. Kargl  <kargls@comcast.net>

	* gfortran.h (gfc_real_info): Add subnormal struct member.
	* arith.c (gfc_arith_init_1): Set it.
	(gfc_check_real_range): Use it.
	* simplify.c (gfc_simplify_nearest): Fix nearest(0.,1.).

2005-04-13  Steven G. Kargl  <kargls@comcast.net>

	* gfortran.dg/underflow.f90: Use tiny(x)/huge(x).

-- 
Steve

Attachment: subnormal.diff
Description: Text document

Attachment: underflow.diff
Description: Text document


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