From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fadul-0008TO-DM for qemu-devel@nongnu.org; Mon, 01 May 2006 15:18:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fadue-0008NW-9E for qemu-devel@nongnu.org; Mon, 01 May 2006 15:18:34 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fadue-0008NR-3A for qemu-devel@nongnu.org; Mon, 01 May 2006 15:18:28 -0400 Received: from [66.93.172.17] (helo=nevyn.them.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FadyP-0002lI-PL for qemu-devel@nongnu.org; Mon, 01 May 2006 15:22:22 -0400 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FaduN-0002sv-2Y for qemu-devel@nongnu.org; Mon, 01 May 2006 15:18:11 -0400 Date: Mon, 1 May 2006 15:18:11 -0400 From: Daniel Jacobowitz Subject: Re: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract Message-ID: <20060501191811.GA10837@nevyn.them.org> References: <44565680.4050003@mail.berlios.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44565680.4050003@mail.berlios.de> 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 On Mon, May 01, 2006 at 08:42:08PM +0200, Stefan Weil wrote: > >- if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) { > >+ if (~(T0 ^ T1) & (T0 ^ tmp) & 0x80000000) { > Hello Dirk, > > which additions / subtractions are handled incorrectly by the current code? > Here is the result of a test which shows that the current code (which is > based on my patch) > raises an exception for 0x80000000 + 0x80000000. > > Daniel, perhaps you could sent the code you used to check overflow > conditions? I used GDB. (gdb) set $T0 = 0x80000000 (gdb) set $T1 = 0x80000000 (gdb) set $tmp = $T0 + $T1 (gdb) p (($tmp ^ $T1 ^ (-1)) & ($T0 ^ $T1)) >> 31 $1 = 0 I see no reason why it should be wrong. $tmp is of course zero. The high bit of tmp is not the same as the high bit of T1, therefore $tmp ^ $T1 ^ (-1) == 0. Therefore the if is false. I even compiled and ran the sample -> no exception. Oh, damn! tmp is not the result, T0 is the result. No wonder this didn't make any sense. I apologize, I'm really batting zero today. -- Daniel Jacobowitz CodeSourcery