All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"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: Mon, 5 Aug 2019 14:13:14 -0700	[thread overview]
Message-ID: <d788f3ff-6814-117d-942d-7870b6201f30@twiddle.net> (raw)
In-Reply-To: <20190805180332.10185-1-peter.maydell@linaro.org>

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~


  parent reply	other threads:[~2019-08-05 21:14 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 [this message]
2019-08-05 23:16   ` Paolo Bonzini
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=d788f3ff-6814-117d-942d-7870b6201f30@twiddle.net \
    --to=rth@twiddle.net \
    --cc=alex.bennee@linaro.org \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.