From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uj9PE-0006b3-Ab for qemu-devel@nongnu.org; Sun, 02 Jun 2013 10:37:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uj9PD-0003iV-Ie for qemu-devel@nongnu.org; Sun, 02 Jun 2013 10:37:12 -0400 Received: from mail-we0-x22e.google.com ([2a00:1450:400c:c03::22e]:46992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uj9PD-0003iH-DV for qemu-devel@nongnu.org; Sun, 02 Jun 2013 10:37:11 -0400 Received: by mail-we0-f174.google.com with SMTP id q58so961498wes.5 for ; Sun, 02 Jun 2013 07:37:10 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51AB588A.9030406@redhat.com> Date: Sun, 02 Jun 2013 16:36:58 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1369948629-2833-1-git-send-email-pbonzini@redhat.com> <1369948629-2833-11-git-send-email-pbonzini@redhat.com> <51A921BF.7040908@twiddle.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 10/21] memory: make section size a 128-bit integer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, Richard Henderson Il 02/06/2013 16:18, Peter Maydell ha scritto: > On 31 May 2013 23:18, Richard Henderson wrote: >> On 05/30/2013 02:16 PM, Paolo Bonzini wrote: >>> +static inline Int128 int128_rshift(Int128 a, int n) >>> +{ >>> + return (Int128) { (a.lo >> n) | (a.hi << (64 - n)), (a.hi >> n) }; >>> +} >> >> Produces wrong results for n == 0, since (a.hi << 64) is undefined. > > It produces wrong results for shifts by more than 64, > for that matter. This should work: int64_t h; if (!n) { return a; } h = a.hi >> n; if (n >= 64) { return (Int128) { h, h >> 63 }; } else { return (Int128) { (a.lo >> n) | (a.hi << (64 - n)), h }; } Paolo