[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] target-i386/FPU: wrong conversion infinity from
From: |
Dmitry Poletaev |
Subject: |
Re: [Qemu-devel] [PATCH] target-i386/FPU: wrong conversion infinity from float80 to int32/int64 |
Date: |
Wed, 23 Jul 2014 19:04:36 +0400 |
I'm understood. So, am I right?
From: Dmitry Poletaev <address@hidden>
Signed-off-by: Dmitry Poletaev <address@hidden>
---
target-i386/fpu_helper.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c
index 1b2900d..c4fdad8 100644
--- a/target-i386/fpu_helper.c
+++ b/target-i386/fpu_helper.c
@@ -251,16 +251,31 @@ 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 = env->fp_status.float_exception_flags;
+ env->fp_status.float_exception_flags = 0;
val = floatx80_to_int32(ST0, &env->fp_status);
+ if (env->fp_status.float_exception_flags & FPUS_IE) {
+ val = 0x80000000;
+ }
+ env->fp_status.float_exception_flags |= old_exp_flags;
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 = env->fp_status.float_exception_flags;
+ env->fp_status.float_exception_flags = 0;
+
+ val = floatx80_to_int64(ST0, &env->fp_status);
+ if (env->fp_status.float_exception_flags & FPUS_IE) {
+ val = 0x8000000000000000;
+ }
+ env->fp_status.float_exception_flags |= old_exp_flags;
return val;
}
--
1.8.4.msysgit.0
23.07.2014, 16:42, "Peter Maydell" <address@hidden>:
> On 23 July 2014 12:55, Dmitry Poletaev <address@hidden> wrote:
>> 14.07.2014, 18:59, "Peter Maydell" <address@hidden>:
>>> Since softfloat's status flags are sticky ...
>> What does it mean?
>
> "Sticky" here means that the status flags accumulate the
> status from a sequence of operations: a softfloat function
> will set the flag if the relevant exception occurred, but if
> the exceptional condition did not happen then the flag will
> be left at whatever its preceding value was. So you can't
> just say "if the flag is set then the last operation I did set
> it", because it might have been set by some operation
> before that. (That is, once a bit gets set in the flags word
> it "sticks" and doesn't go away.)
>
> This matches the IEEE mandated behaviour for
> floating point exception flags, which is why we do it.
>
> thanks
> -- PMM