summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorJoseph Myers2020-05-14 01:50:19 +0200
committerPaolo Bonzini2020-06-10 18:10:24 +0200
commit34b9cc076ff423023a779a04a9f7cd7c17372cbf (patch)
treeda8938f804746da92052eebfe180c67b473d885a /target
parenttarget/i386: fix floating-point load-constant rounding (diff)
downloadqemu-34b9cc076ff423023a779a04a9f7cd7c17372cbf.tar.gz
qemu-34b9cc076ff423023a779a04a9f7cd7c17372cbf.tar.xz
qemu-34b9cc076ff423023a779a04a9f7cd7c17372cbf.zip
target/i386: fix fxam handling of invalid encodings
The fxam implementation does not check for invalid encodings, instead treating them like NaN or normal numbers depending on the exponent. Fix it to check that the high bit of the significand is set before treating an encoding as NaN or normal, thus resulting in correct handling (all of C0, C2 and C3 cleared) for invalid encodings. Signed-off-by: Joseph Myers <joseph@codesourcery.com> Message-Id: <alpine.DEB.2.21.2005132349311.11687@digraph.polyomino.org.uk> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target')
-rw-r--r--target/i386/fpu_helper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c
index f0b9cb5de8..185493db8e 100644
--- a/target/i386/fpu_helper.c
+++ b/target/i386/fpu_helper.c
@@ -1099,7 +1099,7 @@ void helper_fxam_ST0(CPUX86State *env)
if (expdif == MAXEXPD) {
if (MANTD(temp) == 0x8000000000000000ULL) {
env->fpus |= 0x500; /* Infinity */
- } else {
+ } else if (MANTD(temp) & 0x8000000000000000ULL) {
env->fpus |= 0x100; /* NaN */
}
} else if (expdif == 0) {
@@ -1108,7 +1108,7 @@ void helper_fxam_ST0(CPUX86State *env)
} else {
env->fpus |= 0x4400; /* Denormal */
}
- } else {
+ } else if (MANTD(temp) & 0x8000000000000000ULL) {
env->fpus |= 0x400;
}
}