This is the mail archive of the gcc@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]

Re: FWD: FLOATING-POINT CONSISTENCY, -FFLOAT-STORE, AND X86


Craig Burley <burley@gnu.org> writes:

 > So, I think gcc is closer to this latter case of yours than the former,
 > although I'm uncomfortable saying that "everything always stays in
 > FP registers except for spills", not having studied the issues.

The *only* way to get correct numerics is to guarantee that values
can't go from higher precision to lower precision and back to higher
precision.  Once this happens then you're left with the possibility of
computations sometimes using higher precision & sometimes lower
precision, and having seemingly identical computations produce results
which don't test for equality - i.e. - all the problems with the
current defaults.

Given this, then doing 80 bit spills will fix things *only* if you
guarantee that once a value hits the FPU it remains 80 bit (aka 80 bit
contagion).  I.e. - the compiler can't store back into a double (for
example) and then fetch this value back for additional computations.
It has to always get the value from 80 bit memory instead.

If gcc actually does this, then great.  80 bit spills will fix the
numerics and also give the excess precision people are demanding.  I
haven't actually met any of these people, but rumor has it that they
exist. :)

However, if gcc *doesn't* guarantee this, then the numerics will still
suck, even with 80 bit spills.  They'll just suck less often.

On the other hand, running the FPU in 64 bit mode *will* guarantee
this at least for computations done on double precision numbers.  As
for the single precision computations, this property won't hold, so
they'll still suck, *but*, they'll suck exactly as much as the double
precision computations would have sucked with an 80 bit FPU & 80 bit
spills.

So, the summary:

                    FPU width & spill width
                 64                          80
computation
 width

 doubles     Correct.                     Correct *if* you guarantee 
                                          80 bit contagion.

 floats      Correct *if* you guarantee   Correct *if* you guarantee 
             64 bit contagion.            80 bit contagion.

The choice is clear, at least for me.  I'm setting the FPU to 64 bit
mode in all my code.  Maybe I'll even put it in crt0.o.

And I also realized why I'm still arguing about it.  I think people
who find the problem have an easy & reasonable fix, so I don't think
the whole thing really is a big issue.  But, I'd just like the issues
to be clear for all involved.

-- 
Harvey J. Stein
BFM Financial Research
hjstein@bfr.co.il


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