This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

Re: possible optimizer bug in gcc for Red Hat regarding float assignment


Phil Hodge wrote:
The attachment t.i contains the source with include files included.
(Was I supposed to type that file into the description field when
using GCC Bugzilla?  I didn't see any way to include a file.)

If the testcase is large, then file the bug report without the testcase first, wait for the auto-reply, view the bug in a browser, click on the "Create a New Attachment" link, and put your testcase in the attachment.
There might be a better way to do this, but this is one way that works.


When I printed the values of diff and mindiff following the if block
starting with 'if (diff <= mindiff)', the values were slightly different.

This appears to be the infamous x86 "excess precision" problem. The x86 always stores floating point values in registers as 80-bit values. These values can sometimes have "excess precision" bits which get lost when the values are stored to memory. This can cause two different variables which should be equal to compare different, because one is in a register and one is in memory.


This problem has been known for over a decade, and is not easy to fix in the compiler. The problem is due in part to the design of the x86 fpu.

There are some ways to work around this problem. You can avoid using exact compares on FP values by adding an epsilon value to account for excess precision problems. You can try using -ffloat-store which forces fp variables to memory. If you have recent hardware and recent gcc versions, you can try using the SSE registers for floating point. The SSE registers don't have the excess precision problem.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



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