target/i386: fix fisttpl, fisttpll handling of out-of-range values
commitc8af85b10c818709755f5dc8061c69920611fd4c
authorJoseph Myers <joseph@codesourcery.com>
Fri, 15 May 2020 21:20:25 +0000 (15 21:20 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 10 Jun 2020 16:10:26 +0000 (10 12:10 -0400)
tree5b61a69a88ed51a6fdedffd0cad0028362eb5e49
parent374ff4d0a3c2cce2bc6e4ba8a77eaba55c165252
target/i386: fix fisttpl, fisttpll handling of out-of-range values

The fist / fistt family of instructions should all store the most
negative integer in the destination format when the rounded /
truncated integer result is out of range or the input is an invalid
encoding, infinity or NaN.  The fisttpl and fisttpll implementations
(32-bit and 64-bit results, truncate towards zero) failed to do this,
producing the most positive integer in some cases instead.  Fix this
by copying the code used to handle this issue for fistpl and fistpll,
adjusted to use the _round_to_zero functions for the actual
conversion (but without any other changes to that code).

Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Message-Id: <alpine.DEB.2.21.2005152119160.3469@digraph.polyomino.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/fpu_helper.c
tests/tcg/i386/test-i386-fisttp.c [new file with mode: 0644]