public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/30255]  New: register spills in x87 unit need to be 80-bit, not 64
@ 2006-12-18 20:08 whaley at cs dot utsa dot edu
  2006-12-18 20:16 ` [Bug target/30255] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: whaley at cs dot utsa dot edu @ 2006-12-18 20:08 UTC (permalink / raw)
  To: gcc-bugs

Hi,

I am aware that gcc attempts to avoid any reordering of floating-piont
operations by default, as this leads to slightly different answers on different
runs.  There appears to be a similar problem on the x87, where from my
assembly-diving, I believe I've established that when a register spill is
required, gcc only stores to the precision of the computation (eg., 64 bits for
double precision).  On the x87 unit, this therefore introduces an unpredictable
(in the sense that the source does not have a store with its implicit round,
but the executable does) round operation in the middle of the computation. 
This unasked-for round operation has the exact same affect as reordering two fp
computations (eg, it introduces an epsilon error).  This means that not only do
you have differing answers where you don't expect them, but theoretically, the
80-bit x87 could produce less accurate results than true 32 or 64-bit (though
this would almost never happen in practice, as it would require massive
spilling).

It came to my attention because a user of my ATLAS library noted that ATLAS
failed to produce a true symmetric matrix when C = A * transpose(A) was taken. 
If there is no reorderings, the lower triangle of C should exactly match the
upper triangle.  When using gcc 4.2.0 20060807 (experimental) a register spill
is introduced in the calculation of a 4x1 sub-block of C.  The spill only
affects the C[0], and that element gets an additional round that other elements
do not, leading to a slightly non-symmetric matrix.

Note that this is not stores in the algorithm causing rounding (which is
inevitable), but stores unpredictably introduced into the algorithm by gcc.

A complete fix for this problem is to always do 80-bit register spills for the
x87, regardless of the data type of the final calculation, and thus avoid the
unpredictable round steps.

In order to get the problem, you need a code that has a spill, and depends on
getting the same answer to one spilled and one unspilled redundant calculation.
 I have a test case that does so for the above experimental gcc, but not for
gcc 4.1.1 20060525 (Red Hat 4.1.1-1), since this earlier one doesn't inject a
spill in the right place.  I have not tried on various other compiler versions,
because I figure this is a general policy, and if I have figured the problem
right, you can confirm easily how many bits you spill from the x87.

If you are interested in making the x87 produce the same answer in this case,
and it is helpful, I can certainly post my tester that demonstrates the
problem.  I don't want to go through the trouble if the answer is either
"confirmed, not going to fixed", or "confirmed, see how it would cause the
error, will fix".

Let me know,
Clint


-- 
           Summary: register spills in x87 unit need to be 80-bit, not 64
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: whaley at cs dot utsa dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30255


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-02-16 13:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-30255-4@http.gcc.gnu.org/bugzilla/>
2014-02-16 13:13 ` [Bug target/30255] register spills in x87 unit need to be 80-bit, not 64 jackie.rosen at hushmail dot com
2006-12-18 20:08 [Bug target/30255] New: " whaley at cs dot utsa dot edu
2006-12-18 20:16 ` [Bug target/30255] " pinskia at gcc dot gnu dot org
2006-12-18 20:43 ` whaley at cs dot utsa dot edu
2006-12-18 21:17 ` whaley at cs dot utsa dot edu
2006-12-18 22:04 ` pinskia at gcc dot gnu dot org
2006-12-18 22:14 ` whaley at cs dot utsa dot edu
2006-12-18 23:03 ` pinskia at gcc dot gnu dot org
2006-12-19  0:32 ` whaley at cs dot utsa dot edu
2006-12-19 14:57 ` ian at airs dot com
2006-12-19 16:04 ` whaley at cs dot utsa dot edu
2006-12-19 17:18 ` whaley at cs dot utsa dot edu
2006-12-27 16:22 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).