From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FZVBR-00009s-PE for qemu-devel@nongnu.org; Fri, 28 Apr 2006 11:47:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FZVBP-00007N-NC for qemu-devel@nongnu.org; Fri, 28 Apr 2006 11:47:04 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FZVBP-000073-H8 for qemu-devel@nongnu.org; Fri, 28 Apr 2006 11:47:03 -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 1FZVEZ-00083u-D8 for qemu-devel@nongnu.org; Fri, 28 Apr 2006 11:50:19 -0400 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FZVBN-00084Z-Mi for qemu-devel@nongnu.org; Fri, 28 Apr 2006 11:47:01 -0400 Date: Fri, 28 Apr 2006 11:47:01 -0400 From: Daniel Jacobowitz Subject: Re: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add / subtract Message-ID: <20060428154701.GA30778@nevyn.them.org> References: <443E9D2F.5050807@mail.berlios.de> <20060428132818.GA27384@nevyn.them.org> <44522BFB.8030109@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44522BFB.8030109@gmail.com> 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 Fri, Apr 28, 2006 at 04:51:39PM +0200, Dirk Behme wrote: > Daniel Jacobowitz wrote: > >I haven't tested the patched qemu, but I did test the expressions > >themselves in standalone code, and they definitely do not detect > >overflow. > > Maybe you can test Ralf's alternative proposal > > http://lists.gnu.org/archive/html/qemu-devel/2006-02/msg00154.html > > as well? Using 64-bit math for this would be awful for performance. My original checks were wrong; we just need to use a correct fix... Lightly tested, but I think this is right for add: - if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) { + if (~(T0 ^ T1) & (T0 ^ tmp) & 0x80000000) { And this for sub: - if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) { + if ((T0 ^ T1) & (T0 ^ tmp) & 0x80000000) { -- Daniel Jacobowitz CodeSourcery