Received: from eggs.gnu.org ([2001:4830:134:3::10]:60021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9y63-0004Ie-Cd for qemu-devel@nongnu.org; Wed, 23 Jul 2014 11:04:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X9y5w-0004Iy-1V for qemu-devel@nongnu.org; Wed, 23 Jul 2014 11:04:47 -0400 Received: from forward1h.mail.yandex.net ([84.201.187.146]:40033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9y5v-0004Iq-N1 for qemu-devel@nongnu.org; Wed, 23 Jul 2014 11:04:39 -0400 From: Dmitry Poletaev In-Reply-To: References: <3936561405348528@web11m.yandex.ru> <5212091406116528@web27m.yandex.ru> MIME-Version: 1.0 Message-Id: <3654261406127876@web2h.yandex.ru> Date: Wed, 23 Jul 2014 19:04:36 +0400 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] target-i386/FPU: wrong conversion infinity from float80 to int32/int64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers I'm understood. So, am I right? From: Dmitry Poletaev Signed-off-by: Dmitry Poletaev --- 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; + =20 + old_exp_flags =3D env->fp_status.float_exception_flags; + env->fp_status.float_exception_flags =3D 0; val =3D floatx80_to_int32(ST0, &env->fp_status); + if (env->fp_status.float_exception_flags & FPUS_IE) { + val =3D 0x80000000; + } + env->fp_status.float_exception_flags |=3D old_exp_flags; return val; } =20 int64_t helper_fistll_ST0(CPUX86State *env) { int64_t val; - - val =3D floatx80_to_int64(ST0, &env->fp_status); + signed char old_exp_flags; + =20 + old_exp_flags =3D env->fp_status.float_exception_flags; + env->fp_status.float_exception_flags =3D 0; + + val =3D floatx80_to_int64(ST0, &env->fp_status); =20 + if (env->fp_status.float_exception_flags & FPUS_IE) { + val =3D 0x8000000000000000; + } + env->fp_status.float_exception_flags |=3D old_exp_flags; return val; } =20 --=20 1.8.4.msysgit.0 23.07.2014, 16:42, "Peter Maydell" : > On 23 July 2014 12:55, Dmitry Poletaev wrote: >> =9A14.07.2014, 18:59, "Peter Maydell" : >>> =9A=9ASince softfloat's status flags are sticky ... >> =9AWhat 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