From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upi0I-0005qV-1T for qemu-devel@nongnu.org; Thu, 20 Jun 2013 12:46:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Upi0D-0006oV-EV for qemu-devel@nongnu.org; Thu, 20 Jun 2013 12:46:33 -0400 Received: from mail-qc0-x234.google.com ([2607:f8b0:400d:c01::234]:58011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upi0D-0006oP-A2 for qemu-devel@nongnu.org; Thu, 20 Jun 2013 12:46:29 -0400 Received: by mail-qc0-f180.google.com with SMTP id a1so3796196qcx.25 for ; Thu, 20 Jun 2013 09:46:28 -0700 (PDT) Sender: Richard Henderson Message-ID: <51C331E0.6030402@twiddle.net> Date: Thu, 20 Jun 2013 09:46:24 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1371740457-27445-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1371740457-27445-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] int128: optimize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org On 06/20/2013 08:00 AM, Paolo Bonzini wrote: > static inline Int128 int128_sub(Int128 a, Int128 b) > { > - return int128_add(a, int128_neg(b)); > + uint64_t lo = a.lo - b.lo; > + return (Int128) { lo, (lo < a.lo) + a.hi - b.hi }; This one isn't right. Consider { 2, 0 } - { 2, 0 } lo = 2 - 2 = 0; = { 0, (0 < 2) + 0 - 0 } = { 0, 1 } I'd be happier with a more traditional (Int128){ a.lo - b.lo, a.hi - b.hi - (a.lo < b.lo) }; r~