summaryrefslogtreecommitdiffstats
path: root/target/i386/fpu_helper.c
diff options
context:
space:
mode:
authorJoseph Myers2020-05-07 02:46:28 +0200
committerPaolo Bonzini2020-06-10 18:10:21 +0200
commitc535d68755576bfa33be7aef7bd294a601f776e0 (patch)
treea38e6c956706bdc5786520ade140301433ef73e2 /target/i386/fpu_helper.c
parenttarget/i386: fix fscale handling of infinite exponents (diff)
downloadqemu-c535d68755576bfa33be7aef7bd294a601f776e0.tar.gz
qemu-c535d68755576bfa33be7aef7bd294a601f776e0.tar.xz
qemu-c535d68755576bfa33be7aef7bd294a601f776e0.zip
target/i386: fix fscale handling of rounding precision
The fscale implementation uses floatx80_scalbn for the final scaling operation. floatx80_scalbn ends up rounding the result using the dynamic rounding precision configured for the FPU. But only a limited set of x87 floating-point instructions are supposed to respect the dynamic rounding precision, and fscale is not in that set. Fix the implementation to save and restore the rounding precision around the call to floatx80_scalbn. Signed-off-by: Joseph Myers <joseph@codesourcery.com> Message-Id: <alpine.DEB.2.21.2005070045430.18350@digraph.polyomino.org.uk> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386/fpu_helper.c')
-rw-r--r--target/i386/fpu_helper.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/target/i386/fpu_helper.c b/target/i386/fpu_helper.c
index 72d1e77eb0..4d14c1ca24 100644
--- a/target/i386/fpu_helper.c
+++ b/target/i386/fpu_helper.c
@@ -1001,7 +1001,10 @@ void helper_fscale(CPUX86State *env)
}
} else {
int n = floatx80_to_int32_round_to_zero(ST1, &env->fp_status);
+ signed char save = env->fp_status.floatx80_rounding_precision;
+ env->fp_status.floatx80_rounding_precision = 80;
ST0 = floatx80_scalbn(ST0, n, &env->fp_status);
+ env->fp_status.floatx80_rounding_precision = save;
}
}