target/i386: fix fbstp handling of negative zero

The fbstp implementation stores +0 when the rounded result should be
-0 because it compares an integer value with 0 to determine the sign.
Fix this by checking the sign bit of the operand instead.

Backports commit 18c53e1e73197a24f9f4b66b1276eb9868db5bf0 from qemu
This commit is contained in:
Joseph Myers 2020-06-15 13:08:36 -04:00 committed by Lioncash
parent c796ee5e13
commit 477a0af161

View file

@ -692,11 +692,14 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong ptr)
int v;
target_ulong mem_ref, mem_end;
int64_t val;
CPU_LDoubleU temp;
temp.d = ST0;
val = floatx80_to_int64(ST0, &env->fp_status);
mem_ref = ptr;
mem_end = mem_ref + 9;
if (val < 0) {
if (SIGND(temp)) {
cpu_stb_data_ra(env, mem_end, 0x80, GETPC());
val = -val;
} else {