From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FabVI-0000Dv-HS for qemu-devel@nongnu.org; Mon, 01 May 2006 12:44:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FabVH-0000DE-5V for qemu-devel@nongnu.org; Mon, 01 May 2006 12:44:08 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FabVG-0000D1-Ih for qemu-devel@nongnu.org; Mon, 01 May 2006 12:44:06 -0400 Received: from [64.233.182.188] (helo=nproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FabZ6-0006aE-N7 for qemu-devel@nongnu.org; Mon, 01 May 2006 12:48:05 -0400 Received: by nproxy.gmail.com with SMTP id c31so2050283nfb for ; Mon, 01 May 2006 09:44:05 -0700 (PDT) Message-ID: <44563AEC.8070903@gmail.com> Date: Mon, 01 May 2006 18:44:28 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020104090007050703050706" From: Dirk Behme Subject: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------020104090007050703050706 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Fix overflow conditions for MIPS add/subtract as proposed by Daniel Jacobowitz. http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00538.html Regards Dirk --------------020104090007050703050706 Content-Type: text/plain; name="qemu-mips-overflow.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-mips-overflow.txt" --- target-mips/op.c_orig 2006-04-30 09:40:46.000000000 +0200 +++ target-mips/op.c 2006-04-30 09:41:52.000000000 +0200 @@ -206,7 +206,7 @@ void op_addo (void) tmp = T0; T0 += T1; - if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) { + if (~(T0 ^ T1) & (T0 ^ tmp) & 0x80000000) { /* operands of same sign, result different sign */ CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW); } @@ -225,7 +225,7 @@ void op_subo (void) tmp = T0; T0 = (int32_t)T0 - (int32_t)T1; - if (((tmp ^ T1) & (tmp ^ T0)) >> 31) { + if ((T0 ^ T1) & (T0 ^ tmp) & 0x80000000) { /* operands of different sign, first operand and result different sign */ CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW); } --------------020104090007050703050706--