From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCRWM-0005O2-En for qemu-devel@nongnu.org; Thu, 22 Aug 2013 05:49:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCRWG-00071B-G0 for qemu-devel@nongnu.org; Thu, 22 Aug 2013 05:49:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCRWG-00070z-8j for qemu-devel@nongnu.org; Thu, 22 Aug 2013 05:49:32 -0400 Message-ID: <5215DE80.4030203@redhat.com> Date: Thu, 22 Aug 2013 11:48:48 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1377159632-7446-1-git-send-email-aik@ozlabs.ru> <1377159632-7446-2-git-send-email-aik@ozlabs.ru> <5215D561.3050702@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 1/3] int128: add int128_exts64() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Alexey Kardashevskiy , Alex Williamson , QEMU Developers Il 22/08/2013 11:47, Peter Maydell ha scritto: > On 22 August 2013 10:09, Paolo Bonzini wrote: >> Il 22/08/2013 10:20, Alexey Kardashevskiy ha scritto: >>> +static inline Int128 int128_exts64(int64_t a) >>> +{ >>> + return (Int128) { .lo = a, .hi = (a >> 63) ? -1 : 0 }; >>> +} >> >> The "? -1 : 0" is not necessary, but the compiler will remove it at -O1 >> or more (interestingly, or -O0 it will remove the shift and leave the >> conditional!). > > We can avoid relying on implementation defined > behaviour here by using > .hi = (a < 0) ? -1 : 0; > > (I know we allow ourselves to assume right-shift of signed > ints is arithmetic shift, but I think it's nicer to avoid it unless > it really makes the code better.) This is what Alexey proposed. I suggested (a >> 63) without the ?: but he misunderstood my (probably not clear enough) suggestion. Paolo