All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Poletaev <poletaev-qemu@yandex.ru>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] target-i386/FPU: wrong conversion infinity from float80 to int32/int64
Date: Tue, 11 Nov 2014 15:29:39 +0300	[thread overview]
Message-ID: <185941415708979@web10m.yandex.ru> (raw)
In-Reply-To: <CAFEAcA-1n_ZMfXj6QBZSJ53GTTxMtd6--5W5tzz3bA41mFr6wQ@mail.gmail.com>

From: Dmitry Poletaev <poletaev-qemu@yandex.ru>
Signed-off-by: Dmitry Poletaev <poletaev-qemu@yandex.ru>

---
 target-i386/fpu_helper.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c
index ab19b71..fc25a03 100644
--- a/target-i386/fpu_helper.c
+++ b/target-i386/fpu_helper.c
@@ -251,16 +251,34 @@ int32_t helper_fist_ST0(CPUX86State *env)
 int32_t helper_fistl_ST0(CPUX86State *env)
 {
     int32_t val;
-
+    signed char old_exp_flags;
+    
+    old_exp_flags = get_float_exception_flags(&env->fp_status);
+    set_float_exception_flags(0, &env->fp_status);
+    
     val = floatx80_to_int32(ST0, &env->fp_status);
+    if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) {
+        val = 0x80000000;
+    }
+    set_float_exception_flags(get_float_exception_flags(&env->fp_status)
+                                | old_exp_flags, &env->fp_status);
     return val;
 }

 int64_t helper_fistll_ST0(CPUX86State *env)
 {
     int64_t val;
-
-    val = floatx80_to_int64(ST0, &env->fp_status);
+    signed char old_exp_flags;
+    
+    old_exp_flags = get_float_exception_flags(&env->fp_status);
+    set_float_exception_flags(0, &env->fp_status);
+    
+    val = floatx80_to_int32(ST0, &env->fp_status);
+    if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) {
+        val = 0x8000000000000000ULL;
+    }
+    set_float_exception_flags(get_float_exception_flags(&env->fp_status)
+                                | old_exp_flags, &env->fp_status);
     return val;
 }

-- 
1.8.4.msysgit.0

14.10.2014, 15:56, "Peter Maydell" <peter.maydell@linaro.org>:
> On 14 October 2014 12:38, Dmitry Poletaev <poletaev-qemu@yandex.ru> wrote:
>>  29.07.2014, 23:07, "Richard Henderson" <rth@twiddle.net>:
>>>  On 07/23/2014 05:04 AM, Dmitry Poletaev wrote:
>>>>   +    if (env->fp_status.float_exception_flags & FPUS_IE) {
>>>  Mixing bit masks.  s/FPUS_IE/float_status_invalid/
>
> [Please don't top-post.]
>>  What do you mean?
>
> Richard means that the set of defined flags for
> float_exception_flags does not include "FPUS_IE"
> (which is defining a symbolic constant for a bit
> in an x86 register). You want to use "float_flag_invalid".
> (The two happen to have the same value, 1, which is why
> your code worked by accident.)
>
> thanks
> -- PMM

  reply	other threads:[~2014-11-11 12:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14 14:35 [Qemu-devel] [PATCH] target-i386/FPU: wrong conversion infinity from float80 to int32/int64 Dmitry Poletaev
2014-07-14 14:59 ` Peter Maydell
2014-07-23 11:55   ` Dmitry Poletaev
2014-07-23 12:42     ` Peter Maydell
2014-07-23 15:04       ` Dmitry Poletaev
2014-07-23 17:13         ` Peter Maydell
2014-07-24 10:57           ` Dmitry Poletaev
2014-07-29 19:06         ` Richard Henderson
2014-10-14 10:38           ` Dmitry Poletaev
2014-10-14 10:55             ` Peter Maydell
2014-11-11 12:29               ` Dmitry Poletaev [this message]
2014-11-12  7:47                 ` Richard Henderson

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=185941415708979@web10m.yandex.ru \
    --to=poletaev-qemu@yandex.ru \
    --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 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.