From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MzWko-0001cn-HP for qemu-devel@nongnu.org; Sun, 18 Oct 2009 10:29:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MzWkn-0001cD-QT for qemu-devel@nongnu.org; Sun, 18 Oct 2009 10:29:02 -0400 Received: from [199.232.76.173] (port=48566 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzWkn-0001c7-LF for qemu-devel@nongnu.org; Sun, 18 Oct 2009 10:29:01 -0400 Received: from fg-out-1718.google.com ([72.14.220.152]:31905) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MzWkn-0008EI-95 for qemu-devel@nongnu.org; Sun, 18 Oct 2009 10:29:01 -0400 Received: by fg-out-1718.google.com with SMTP id 16so137766fgg.10 for ; Sun, 18 Oct 2009 07:29:00 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20091015210846.GB7071@volta.aurel32.net> References: <20091015210846.GB7071@volta.aurel32.net> Date: Sun, 18 Oct 2009 16:29:00 +0200 Message-ID: <761ea48b0910180729s1221bf45m4c38303ca2f44657@mail.gmail.com> Subject: Re: [Qemu-devel] [PATCH] target-arm: fix sdiv helper From: Laurent Desnogues Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno Cc: qemu-devel@nongnu.org On Thu, Oct 15, 2009 at 11:08 PM, Aurelien Jarno wro= te: > (INT32_MIN / -1) triggers an overflow, and the result depends on the > host architecture (INT32_MIN on arm, -1 on ppc, SIGFPE on x86). Use a > test to output the correct value. > > Signed-off-by: Aurelien Jarno > --- > =A0target-arm/helper.c | =A0 =A02 ++ > =A01 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/target-arm/helper.c b/target-arm/helper.c > index 701629a..b3d6198 100644 > --- a/target-arm/helper.c > +++ b/target-arm/helper.c > @@ -404,6 +404,8 @@ int32_t HELPER(sdiv)(int32_t num, int32_t den) > =A0{ > =A0 =A0 if (den =3D=3D 0) > =A0 =A0 =A0 return 0; > + =A0 =A0if (num =3D=3D INT_MIN && den =3D=3D -1) > + =A0 =A0 =A0return INT_MIN; > =A0 =A0 return num / den; > =A0} > > -- > 1.6.1.3 Acked-by: Laurent Desnogues That is provided we accept the behaviour for division by zero is not strictly conforming to what the ARM ARM says. Also note this instruction is not available on v7-A CPU's (Cortex-A8 for instance). It's part of v7-R (Cortex R4). Laurent