Received: from eggs.gnu.org ([140.186.70.92]:60908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPZnq-0008OC-Gi for qemu-devel@nongnu.org; Thu, 26 May 2011 08:36:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPZnp-0003FE-L1 for qemu-devel@nongnu.org; Thu, 26 May 2011 08:36:38 -0400 Received: from smtp.ispras.ru ([83.149.198.202]:49687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPZnp-0003E8-Co for qemu-devel@nongnu.org; Thu, 26 May 2011 08:36:37 -0400 Date: Thu, 26 May 2011 16:36:11 +0400 (MSD) From: Kirill Batuzov In-Reply-To: <4DD6B4E9.3040501@twiddle.net> Message-ID: References: <97bbf40c055a9949f5fbf185764792679fb8273a.1305889001.git.batuzovk@ispras.ru> <4DD6B4E9.3040501@twiddle.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH 5/6] Do constant folding for shift operations. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: mj.mccormack@samsung.com, qemu-devel@nongnu.org, zhur@ispras.ru On Fri, 20 May 2011, Richard Henderson wrote: > > On 05/20/2011 05:39 AM, Kirill Batuzov wrote: > > + case INDEX_op_sar_i32: > > +#if TCG_TARGET_REG_BITS == 64 > > + x &= 0xffffffff; > > + y &= 0xffffffff; > > +#endif > > + r = x & 0x80000000; > > + x &= ~0x80000000; > > + x >>= y; > > + r |= r - (r >> y); > > + x |= r; > > + return x; > > + > > Any reason you're emulating the 32-bit shift by > hand, rather than letting the compiler do it? I.e. > > x = (int32_t)x >> (int32_t)y; > This expression has an implementation-defined behavior accroding to C99 6.5.7 so we decided to emulate signed shifts by hand. ---- Kirill.