[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/31] softfloat: do not return pseudo-denormal from floatx80 rema
From: |
Paolo Bonzini |
Subject: |
[PULL 17/31] softfloat: do not return pseudo-denormal from floatx80 remainder |
Date: |
Wed, 24 Jun 2020 06:50:34 -0400 |
From: Joseph Myers <joseph@codesourcery.com>
The floatx80 remainder implementation sometimes returns the numerator
unchanged when the denominator is sufficiently larger than the
numerator. But if the value to be returned unchanged is a
pseudo-denormal, that is incorrect. Fix it to normalize the numerator
in that case.
Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <alpine.DEB.2.21.2006081655520.23637@digraph.polyomino.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
fpu/softfloat.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index f164b5c0ad..ab50088c35 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -5706,7 +5706,7 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, bool mod,
float_status *status)
{
bool aSign, zSign;
- int32_t aExp, bExp, expDiff;
+ int32_t aExp, bExp, expDiff, aExpOrig;
uint64_t aSig0, aSig1, bSig;
uint64_t q, term0, term1, alternateASig0, alternateASig1;
@@ -5715,7 +5715,7 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, bool mod,
return floatx80_default_nan(status);
}
aSig0 = extractFloatx80Frac( a );
- aExp = extractFloatx80Exp( a );
+ aExpOrig = aExp = extractFloatx80Exp( a );
aSign = extractFloatx80Sign( a );
bSig = extractFloatx80Frac( b );
bExp = extractFloatx80Exp( b );
@@ -5730,6 +5730,13 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, bool
mod,
if ((uint64_t)(bSig << 1)) {
return propagateFloatx80NaN(a, b, status);
}
+ if (aExp == 0 && aSig0 >> 63) {
+ /*
+ * Pseudo-denormal argument must be returned in normalized
+ * form.
+ */
+ return packFloatx80(aSign, 1, aSig0);
+ }
return a;
}
if ( bExp == 0 ) {
@@ -5749,7 +5756,16 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, bool
mod,
expDiff = aExp - bExp;
aSig1 = 0;
if ( expDiff < 0 ) {
- if ( mod || expDiff < -1 ) return a;
+ if ( mod || expDiff < -1 ) {
+ if (aExp == 1 && aExpOrig == 0) {
+ /*
+ * Pseudo-denormal argument must be returned in
+ * normalized form.
+ */
+ return packFloatx80(aSign, aExp, aSig0);
+ }
+ return a;
+ }
shift128Right( aSig0, 0, 1, &aSig0, &aSig1 );
expDiff = 0;
}
--
2.26.2
- [PULL 10/31] docs/nvdimm: add description of alignment requirement of device dax, (continued)
- [PULL 10/31] docs/nvdimm: add description of alignment requirement of device dax, Paolo Bonzini, 2020/06/24
- [PULL 11/31] hw/scsi/megasas: Fix possible out-of-bounds array access in tracepoints, Paolo Bonzini, 2020/06/24
- [PULL 15/31] softfloat: merge floatx80_mod and floatx80_rem, Paolo Bonzini, 2020/06/24
- [PULL 16/31] softfloat: fix floatx80 remainder pseudo-denormal check for zero, Paolo Bonzini, 2020/06/24
- [PULL 18/31] softfloat: do not set denominator high bit for floatx80 remainder, Paolo Bonzini, 2020/06/24
- [PULL 12/31] Makefile: Install qemu-[qmp/ga]-ref.* into the directory "interop", Paolo Bonzini, 2020/06/24
- [PULL 14/31] target/i386: reimplement f2xm1 using floatx80 operations, Paolo Bonzini, 2020/06/24
- [PULL 20/31] target/i386: reimplement fprem, fprem1 using floatx80 operations, Paolo Bonzini, 2020/06/24
- [PULL 19/31] softfloat: return low bits of quotient from floatx80_modrem, Paolo Bonzini, 2020/06/24
- [PULL 24/31] target/i386: Add notes for versioned CPU models, Paolo Bonzini, 2020/06/24
- [PULL 17/31] softfloat: do not return pseudo-denormal from floatx80 remainder,
Paolo Bonzini <=
- [PULL 23/31] target/i386: reimplement fpatan using floatx80 operations, Paolo Bonzini, 2020/06/24
- [PULL 27/31] kvm: i386: allow TSC to differ by NTP correction bounds without TSC scaling, Paolo Bonzini, 2020/06/24
- [PULL 21/31] target/i386: reimplement fyl2xp1 using floatx80 operations, Paolo Bonzini, 2020/06/24
- [PULL 25/31] osdep: Make MIN/MAX evaluate arguments only once, Paolo Bonzini, 2020/06/24
- [PULL 22/31] target/i386: reimplement fyl2x using floatx80 operations, Paolo Bonzini, 2020/06/24
- [PULL 30/31] ibex_uart: fix XOR-as-pow, Paolo Bonzini, 2020/06/24
- [PULL 28/31] hyperv: vmbus: Remove the 2nd IRQ, Paolo Bonzini, 2020/06/24