This is the mail archive of the
mailing list for the GCC project.
Re: Floating point problems (accuracy).
On Tue, Jan 18, 2005 at 04:31:05PM -0600, Chris Lattner wrote:
> >Modulo double rounding of course.
> Care to elaborate?
Initial computation is rounded to 64-bits (XFmode) in the register.
The store to memory rounds to 53-bits (DFmode). We have just
rounded twice. Since 64 < 53*2, we _know_ there are cases that are
incorrect because of this.
Note that for SFmode, 24*2 = 48, which is less than both 53 and 64,
so double rounding from DFmode or XFmode comes out correct.
The only way around this is to change the rounding precision of the
fpu to match up with the computation mode of every instruction.
Unfortunately, the 387 lets this rounding precision affect load
and store instructions, so this affects spill code generation too.
And the rounding precision of the fpu does not affect the width of
the exponent in the register, so you _still_ need to spill intermediate
values to memory in order to properly overflow to Infinity.
All in all, it makes for a problem Just Not Worth Solving.
Much better to just fix the hardware, which we sorta do by
using SSE registers instead.