From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu1yz-0002rA-3u for qemu-devel@nongnu.org; Tue, 02 Jul 2013 10:55:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uu1yt-0005Zr-20 for qemu-devel@nongnu.org; Tue, 02 Jul 2013 10:55:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu1ys-0005ZQ-Mm for qemu-devel@nongnu.org; Tue, 02 Jul 2013 10:54:58 -0400 Message-ID: <51D2E9BC.1060401@redhat.com> Date: Tue, 02 Jul 2013 16:54:52 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] int128: optimize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jay Foad Cc: qemu-devel@nongnu.org Il 02/07/2013 14:46, Jay Foad ha scritto: >> static inline Int128 int128_neg(Int128 a) >> { >> - a.lo = ~a.lo; >> - a.hi = ~a.hi; >> - return int128_add(a, int128_one()); >> + uint64_t lo = -a.lo; >> + return (Int128) { lo, ~a.hi + !lo }; >> } > > This leaves int128_one unused. (Also the temporary lo seems a bit > pointless, since you could just as well write -a.lo and !a.lo.) The unused int128_one is not a problem, someone might find a use later. >> static inline bool int128_ge(Int128 a, Int128 b) >> { >> - return int128_nonneg(int128_sub(a, b)); >> + return a.hi > b.hi || (a.hi == b.hi && a.lo >= b.lo); >> } > > This is a bug fix. The old version gives the wrong answer when a and b > are both large and have opposite signs. We don't really use Int128's that are bigger than 2^64, but you are right. I'll add this to the commit message. Paolo