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: Bug with g77 and -mieee on Alpha Linux


> 2. [This one is from hearsay, on comp.arch]  One can only set the
>    rounding mode on the ix86, not the range.  That means that the
>    register values still will not have the same non-finite behaviour
>    as stored values.

Based on my imperfect understanding of what you're saying, and on
my potentially imperfect undrstanding of the FP unit, I may be saying
something you already know, but also I may be adding something,
so I'll take the chance...  (I also came into this late.)

Rounding mode only affects STORE operations.
Thus, setting the rounding mode to 53 bits has no effect on the content
of a register (even after a subsequent arithmetic operation).  The only
way I was able to find that caused a round down from 64-bit to 53 bit
mantissa was a store-load sequence.  (One would hope that there's
a way to fix this in the newer versions, but this was a PII architecture
book I was looking at.)

I spent a lot of time looking at the FP registers very carefully, and
couldn't make them round to the right precision any way *I* could
find that didn't involve memory.   Thus, I believe the problem is worse than
just spills; computations exist which, depending on how many registers the
compiler chooses
to use (and this can be expression order sensitive, of course), the
results could differ (potentially substantially) depending on optimization
level and exact code generation strategies.  (Similar differences would
not be visible on a pure 64bit IEEE machine such as most of the RISCs.)

I pushed on this hard enough that I hacked up gdb to print out
the x86 FP registers in both hex and float decimal, along with intepreted
values of the control registers and a TOS marker.  It helped a lot.
(This is for an older gdb, and I haven't converted it to a patch, but
I'll be happy to ship the file to someone to convert it to a newer
gdb; the changes should be easily portable.)

Donn

P.S.  Thinking about it, there may be a way to get that rounding by
extracting exponents and stuffing mantissas, but I don't really want to
think about that, and it's not clear that it would be any faster than a
store-load, allowing for cache.



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