[Bug target/52451] gcc w/i387 float generates fucom rather than fcom for floating point comparsons
nszabolcs at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Sep 11 16:11:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52451
Szabolcs Nagy <nszabolcs at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nszabolcs at gmail dot com
--- Comment #4 from Szabolcs Nagy <nszabolcs at gmail dot com> ---
this bug is still present in gcc-4.9 on i386 and x86_64 targets
and possibly others (clang is broken too but that's another story)
the ieee-754 and thus iso c99/c11 + annex f, requires that
==, != are quiet (never raise any exception)
<, >, <=, >= are signaling (raise invalid if an operand is nan)
eg. with
int f(float x, float y)
{
return x < y;
}
int g(float x, float y)
{
return x == y;
}
on x87 (i386):
fcom* should be used for f (signaling)
fucom* should be used for g (quiet)
with sse2 (x86_64):
comis* should be used for f (signaling)
ucomis* should be used for g (quiet)
(on arm it is vcmpe.f32 vs vcmp.f32)
it is easy to check that gcc always emits quiet comparisions
and with -mno-ieee-fp it always emits signaling ones
(both of them are wrong)
-O2 -std=c99 on x86_64:
http://goo.gl/awmRGP
-O2 -std=c99 -mno-ieee-fp on x86_64:
http://goo.gl/9CHNjK
More information about the Gcc-bugs
mailing list