Attempting to run the GCC and glibc testsuites for i686 under QEMU shows up a range of bugs in the x87 floating-point emulation. This series fixes some bugs (found both through those testsuites and through subsequent code inspection) that appear to be in the softfloat code itself rather than in the target/i386 code; I intend to address such bugs in target/i386 separately.
Note that the floatx80 code is used for both i386 and m68k emulation, but the two variants of the floatx80 format are not entirely compatible. Where the code should do different things for i386 and m68k, it consistently only does the thing that is right for i386, not the thing that is right for m68k, and my patches (specifically, the second and third patches) continue this, doing the things that are right for i386 but not for m68k. Specifically, the formats have the following differences (based on documentation; I don't have m68k hardware to test): * For m68k, the explicit integer bit of the significand may be either 0 or 1 for infinities and NaNs, but for i386 it must be 1 and having 0 there makes it an invalid encoding. * For i386, when the biased exponent is 0, this is interpreted the same way as a biased exponent of 0 in an IEEE format; an explicit integer bit 0 means a subnormal value while an explicit integer bit 1 means a pseudo-denormal; the integer bit has value 2^-16382, as for a biased exponent of 1. For m68k, a biased exponent of 0 results in the integer bit having value 2^-16383, so values with integer bit 1 are normal and those with integer bit 0 are subnormal. So the least subnormal value is 2^-16445 for i386 and 2^-16446 for m68k. (This means that the i386 floatx80 format meets the IEEE definition of an extended format, which requires a certain relation between the largest and smallest exponents, but the m68k floatx80 format does not meet that definition.) Patches 2 and 3 in this series deal with pseudo-denormals in a way that is correct for i386 but not for m68k; to support the m68k format properly, the new code in patch 3 could simply be disabled for m68k, but addition / subtraction would need more complicated changes to be correct for m68k and just disabling the new code would not make it correct (likewise, various changes elsewhere in the softfloat code would be needed to handle the m68k semantics for biased exponent 0). Joseph Myers (4): softfloat: silence sNaN for conversions to/from floatx80 softfloat: fix floatx80 pseudo-denormal addition / subtraction softfloat: fix floatx80 pseudo-denormal comparisons softfloat: fix floatx80 pseudo-denormal round to integer fpu/softfloat.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) -- 2.17.1 -- Joseph S. Myers jos...@codesourcery.com