From: Paolo Bonzini <pbonzini@redhat.com>
To: Richard Henderson <rth@twiddle.net>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Eduardo Habkost" <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] target/i386: Return 'indefinite integer value' for invalid SSE fp->int conversions
Date: Tue, 6 Aug 2019 01:16:28 +0200 [thread overview]
Message-ID: <56162c59-9da9-d15a-a216-530c673b4592@redhat.com> (raw)
In-Reply-To: <d788f3ff-6814-117d-942d-7870b6201f30@twiddle.net>
On 05/08/19 23:13, Richard Henderson wrote:
> On 8/5/19 11:03 AM, Peter Maydell wrote:
>> The x86 architecture requires that all conversions from floating
>> point to integer which raise the 'invalid' exception (infinities of
>> both signs, NaN, and all values which don't fit in the destination
>> integer) return what the x86 spec calls the "indefinite integer
>> value", which is 0x8000_0000 for 32-bits or 0x8000_0000_0000_0000 for
>> 64-bits. The softfloat functions return the more usual behaviour of
>> positive overflows returning the maximum value that fits in the
>> destination integer format and negative overflows returning the
>> minimum value that fits.
>>
>> Wrap the softfloat functions in x86-specific versions which
>> detect the 'invalid' condition and return the indefinite integer.
>>
>> Note that we don't use these wrappers for the 3DNow! pf2id and pf2iw
>> instructions, which do return the minimum value that fits in
>> an int32 if the input float is a large negative number.
>>
>> Fixes: https://bugs.launchpad.net/qemu/+bug/1815423
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> I've tested that this fixes the LP:1815423 test case. If anybody
>> has an x86 VM image to hand that has node.js installed it would
>> also be useful to test the operations in
>> https://bugs.launchpad.net/qemu/+bug/1832281
>> (I don't have such a VM.)
>>
>> The other approach here would be to make the softfloat functions be
>> flexible enough to allow this behaviour -- from my reading of IEEE754
>> I think the exact returned result for 'invalid' inputs for float to
>> int conversions is not specified.
>>
>> target/i386/ops_sse.h | 88 +++++++++++++++++++++++++++++--------------
>> 1 file changed, 60 insertions(+), 28 deletions(-)
>
> I guess this is exactly what we already do in fpu_helper.c.
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
>
> r~
>
Queued, thanks.
Paolo
next prev parent reply other threads:[~2019-08-05 23:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-05 18:03 [Qemu-devel] [PATCH] target/i386: Return 'indefinite integer value' for invalid SSE fp->int conversions Peter Maydell
2019-08-05 18:17 ` no-reply
2019-08-05 21:13 ` Richard Henderson
2019-08-05 23:16 ` Paolo Bonzini [this message]
2019-08-06 10:52 ` Peter Maydell
2019-08-06 10:20 ` Peter Maydell
2019-08-05 21:26 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56162c59-9da9-d15a-a216-530c673b4592@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=ehabkost@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).