This is the mail archive of the
mailing list for the GCC project.
Re: Handling non-constant bounds in extract_range_from_cond
- From: Geert Bosch <bosch at gnat dot com>
- To: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Cc: pinskia at physics dot uc dot edu, gcc-patches at gcc dot gnu dot org
- Date: Sat, 27 Nov 2004 10:56:21 -0500
- Subject: Re: Handling non-constant bounds in extract_range_from_cond
- References: <10411251436.AA04182@vlsi1.ultra.nyu.edu>
On Nov 25, 2004, at 09:36, Richard Kenner wrote:
It fixes an ICE and I thought it was just cc1221d (I meant to include
that in my email; sorry if I forgot). I show c34002a as working in a
recent run I did, but c460007 is still failing.
c460007 is on my plate. Interesting case of wrong rounding in
float-to-int conversion, fix is known, patch will follow.
Basically, for rounding to nearest int (rounding halfway values
away from zero), one shouldn't do add/subtract 0.5 and then
truncate, but add/subtract the T'Pred of 0.5, where T is a
floating-point type and 'Pred is the predecessor function.
This is because the sum of 0.5 and T'Pred (0.5) is exactly
between two representable numbers and therefore rounded to 1.
Additionally, for floating-point integers with the radix
point directly following the mantissa, adding 0.5 also ends
up halfway two numbers which results in rounding these integers
up to the next integer.
Computing T'Truncate (X + Copy_Sign (T'Pred (0.5), X)) nicely
deals with all these cases.
PS. Fortran has a similar bug.