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]

[Bug middle-end/54550] GCC -O3 breaks floating point equality comparison


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

--- Comment #6 from Veiokej <veiokej at gmail dot com> 2012-09-12 04:14:52 UTC ---
In the process of trying to create a demo, I think I found the problem.

Indeed, no math is taking place between when the value X is first computed and
stored to the list, and when it's compared for equality with the nearest value
Y found in the list. (They should be identical.)

I think that X is observed to be unequal to Y because X is cached in a
register, despite the fact that Y is computed in a (later) function. (Evidence
is that removing -finline_functions, as does -ffloat-store fixes the problem.)

When I was printing the value previously, I was inadvertently causing both X
and Y to be stored to memory as 64-bit doubles, then taking the difference
after the fact, which of course turned out to be 0. The difference was actually
closer to 6x10^(-17).

So this demonstrates how the previously well known excess precision issue can
actually cause equality testing to fail, even when no math is involved between
the store to memory, and the compare with memory. Yikes!

Thankfully this is fixable by using full 80-bit precision, or migrating to X64.

Let's leave this on the record for documentation, but I don't think it's worth
further pursuit. Thanks to all for your input.


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