From 6b63555a006e1c7cbfc577db44ff7dd54d87380a Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 25 Feb 2021 13:35:16 -0500 Subject: [PATCH] softfloat: fix floatx80 remainder pseudo-denormal check for zero The floatx80 remainder implementation ignores the high bit of the significand when checking whether an operand (numerator) with zero exponent is zero. This means it mishandles a pseudo-denormal representation of 0x1p-16382L by treating it as zero. Fix this by checking the whole significand instead. Backports commit 499a2f7b554a295cfc10f8cd026d9b20a38fe664 from qemu --- qemu/fpu/softfloat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu/fpu/softfloat.c b/qemu/fpu/softfloat.c index 15de9697..8e223a61 100644 --- a/qemu/fpu/softfloat.c +++ b/qemu/fpu/softfloat.c @@ -5703,7 +5703,7 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, bool mod, normalizeFloatx80Subnormal( bSig, &bExp, &bSig ); } if ( aExp == 0 ) { - if ( (uint64_t) ( aSig0<<1 ) == 0 ) return a; + if ( aSig0 == 0 ) return a; normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 ); } bSig |= UINT64_C(0x8000000000000000);