]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
softfloat: fix floatx80 pseudo-denormal comparisons
authorJoseph Myers <joseph@codesourcery.com>
Mon, 4 May 2020 23:39:39 +0000 (23:39 +0000)
committerRichard Henderson <richard.henderson@linaro.org>
Fri, 15 May 2020 18:04:50 +0000 (11:04 -0700)
The softfloat floatx80 comparisons fail to allow for pseudo-denormals,
which should compare equal to corresponding values with biased
exponent 1 rather than 0.  Add an adjustment for that case when
comparing numbers with the same sign.

Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Message-Id: <alpine.DEB.2.21.2005042338470.22972@digraph.polyomino.org.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
fpu/softfloat.c
tests/tcg/i386/test-i386-pseudo-denormal.c

index 6094d267b5279d9203dfd31d975bee0e38b2b0b6..c57f72e3a637ae1cd8db6fa4edae73bb5fe10d9c 100644 (file)
@@ -7966,6 +7966,13 @@ static inline int floatx80_compare_internal(floatx80 a, floatx80 b,
             return 1 - (2 * aSign);
         }
     } else {
+        /* Normalize pseudo-denormals before comparison.  */
+        if ((a.high & 0x7fff) == 0 && a.low & UINT64_C(0x8000000000000000)) {
+            ++a.high;
+        }
+        if ((b.high & 0x7fff) == 0 && b.low & UINT64_C(0x8000000000000000)) {
+            ++b.high;
+        }
         if (a.low == b.low && a.high == b.high) {
             return float_relation_equal;
         } else {
index cfa2a500b0300215022d5ebe7693af70b3094d43..acf2b9cf037f67da6137b244ad234e58cf42ccc6 100644 (file)
@@ -20,5 +20,9 @@ int main(void)
         printf("FAIL: pseudo-denormal add\n");
         ret = 1;
     }
+    if (ld_pseudo_m16382.ld != 0x1p-16382L) {
+        printf("FAIL: pseudo-denormal compare\n");
+        ret = 1;
+    }
     return ret;
 }