Received: from eggs.gnu.org ([2001:4830:134:3::10]:49426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz4f9-0005nJ-13 for qemu-devel@nongnu.org; Tue, 25 Oct 2016 12:33:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bz4f4-0001tw-3n for qemu-devel@nongnu.org; Tue, 25 Oct 2016 12:33:19 -0400 Sender: Richard Henderson References: <1477300500-25930-1-git-send-email-nikunj@linux.vnet.ibm.com> <1477300500-25930-4-git-send-email-nikunj@linux.vnet.ibm.com> <87mvht6k4y.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> From: Richard Henderson Message-ID: Date: Tue, 25 Oct 2016 09:33:09 -0700 MIME-Version: 1.0 In-Reply-To: <87mvht6k4y.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/4] target-ppc: add vrldnmi and vrlwmi instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania , qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Cc: qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com, hegdevasant@linux.vnet.ibm.com, sandipandas1990@gmail.com, ego@linux.vnet.ibm.com On 10/24/2016 11:02 PM, Nikunj A Dadhania wrote: > Richard Henderson writes: > > >> We already have rol32 and rol64. >> >> Which I see are broken for shift == 0. > > I tried with different shift (including 0) in a test program, and the > result is as expected: > > 0: ccddeeff > > static inline unsigned int rol32(unsigned int word, unsigned int shift) > { > return (word << shift) | (word >> (32 - shift)); > } Technically, a shift by 32 is invalid. Practically, there are two common cases: shift >= 32 produces zero and shift is truncated to the word size, both of which produce the correct results here. That said, there's also the case of clang's sanitizers, which will in fact signal this as a runtime error. r~