Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: i387 rounding mode and long double support



On Thu, Jul 21, 2011 at 09:53:20PM +0200, Matthias Drochner wrote:
> 
> joerg%britannica.bec.de@localhost said:
> > i386 and amd64 force the FPU into IEEE double precision
> > rounding mode
> > [...]
> > I do question the use for AMD64 though, because
> > normal float and double operations are done using the SSE units
> 
> I had thought about that too. If we can be sure that the compiler
> really does no "double" arithmetics in the x87 (except transcendent
> functions etc where we don't have exact promises about accuracy
> anyway), this would be feasible.
> 
> You might have a look at the release notes of gcc-4.5 - the section
> about -std=c99 and floating point performance. The gcc developers
> have apparently realized that an x87 in long mode doesn't give
> standards conform rounding. Their workaround is to issue a
> store+load to a "double" memory variable after each operation.
> This kills performance, but not for us, with x87 in "double" mode.
> (needs some definition in gcc's config, didn't commit it yet)

If GCC really wants to use the i387, it certainly has to pay the price.
Either setting the rounding mode in a function or forcing loads/stores
are options for that. I don't think that invalidates what I said though.

> 
> > The alternative would be to
> > either accept that long double doesn't actually have the advertised mantissa
> > length
> 
> FreeBSD deals with that, see the TARGET_96_ROUND_53_LONG_DOUBLE
> definition in gcc.

The problem is not GCC.

> Anyway, this stays a tradeoff between "double" speed and accuracy
> on one side and "long double" mantissa length on the other.
> Given the real-world use of "double" vs "long double", this needs
> more consideration than an "ease porting of a library".

The consideration is having proper long double vs crippled long double.
I can just commit the code and it won't work correctly in the cases of
high precision on AMD64 (and well, i386).

Joerg


Home | Main Index | Thread Index | Old Index