lkml.org 
[lkml]   [2000]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Preventing gcc from aligning stack???
Stefan Monnier wrote:
> >>>>> "H" == H Peter Anvin <hpa@transmeta.com> writes:
> > ICK. I'd really like to see a version which spilled to extended
> > precision.
>
> Why should gcc spill a double (i.e. 64bit) as extended precision ?

So that the behaviour of a program does not depend on whether a register
is spilled. So that you get consistent results from the same code.

The current behaviour means you may compile a program and get certain
results. Then you add a line at the start of the function, and the
complicated calculation at the end now gives different results.

It is not nice for your program to print out different values because
you changed a different part of the program, and it isn't necessary.

Numerical codes, simple things like minimum finders and iterative
solvers, depend on such behaviour.

> Should it also do that with floats (i.e. 32bit) ?

Yes.

> The problem is not that only 64bit are spilled, but that
> 80bits are kept around (instead of 64) if not spilled.

Possibly. That is the other point of view that occurs whenever this
debate appears on the egcs list. You would think that on an x86, to do
that all you do is set the precision register to calculate in 64 bit
precision instead of 80 bits.

Unfortunately, that is not quite perfect. The x86 FPU does not restrict
the exponent in calculations to the range of `double'. So the
underflow, overflow and denormal values all work out wrong. The only
way to guarantee calculations work in 64 bits is to write the results to
memory and read them back. -ffloat-store does that.

> If you want 80bit floating point precision, gcc might support
> it with something like `long double'.

It does. It also uses 80 bits for intermediate calculations because
that is what the x86 FPU does, even when you are loading and storing in
the 64 bit format.

BTW, the 80 bit extended precision format historically only requires 8
byte alignment. I don't know if there's any advantage in giving it
bigger alignment nowadays.

enjoy,
-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.092 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site