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]

Re: [PATCH/gfortran] Fix rounding in constant folding


Steve Kargl wrote:
> Ok to commit to mainline and 4.0?
> 
> 2005-04-09  Steven G. Kargl  <kargls@comcast.net>
> 
> 	* simplify.c (gfc_simplify_anint): Use mpfr_round()
> 	(gfc_simplify_dnint): ditto.
> 	(gfc_simplify_nint): ditto.
> 

This is ok, except:

> 2005-04-09  Steven G. Kargl  <kargls@comcast.net>
> 
> 	* gfortran.dg/nint_1.f90: New test.
> 	* gfortran.dg/anint_1.f90: ditto.

Please add tests for dnint and put all tests into a single testcase.  Please
also add tests for negative constants.  (I think the higher granularity we
gain by testing everything individuality is more than offset by the additional
time it takes the testsuite to run.)

> program nint_1
>   if (nint(8388609.0)  /= 8388609) call abort
>   if (nint(0.49999997) /= 0) call abort
> end program nint_1

I would argue for calculating these magic numbers from the model numbers, i.e.
use nint (nearest (0.5, -1.)).  Unfortunately, my argument fails the real-life
test: nint(nearest(...)) gives the correct result (=zero) with an unpatched
compiler on my box, whereas the literal constant from your example doesn't.
In order of increasing probability: Does mpfr round incorrectly? Do we do
something wrong?  Or am I being stupid?

Oh, and 4.0 is Mark's call.

- Tobi


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