From c675454b27fc250c1d8f51177f647cabf5c040f7 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 15 May 2020 23:59:21 -0400 Subject: [PATCH] softfloat: fix floatx80 pseudo-denormal round to integer The softfloat function floatx80_round_to_int incorrectly handles the case of a pseudo-denormal where only the high bit of the significand is set, ignoring that bit (treating the number as an exact zero) rather than treating the number as an alternative representation of +/- 2^-16382 (which may round to +/- 1 depending on the rounding mode) as hardware does. Fix this check (simplifying the code in the process). Backports commit 9ecaf5ccec13ff2e8fe1e72f6e0f3367d2169c1c 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 199dfa47..5a81781c 100644 --- a/qemu/fpu/softfloat.c +++ b/qemu/fpu/softfloat.c @@ -5703,7 +5703,7 @@ floatx80 floatx80_round_to_int(floatx80 a, float_status *status) } if ( aExp < 0x3FFF ) { if ( ( aExp == 0 ) - && ( (uint64_t) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) { + && ( (uint64_t) ( extractFloatx80Frac( a ) ) == 0 ) ) { return a; } status->float_exception_flags |= float_flag_inexact;