From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNUhS-0002RW-00 for qemu-devel@nongnu.org; Fri, 20 May 2011 14:45:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNUhR-0004Ju-5P for qemu-devel@nongnu.org; Fri, 20 May 2011 14:45:25 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:43190) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNUhR-0004Jn-0E for qemu-devel@nongnu.org; Fri, 20 May 2011 14:45:25 -0400 Received: by pzk30 with SMTP id 30so2232533pzk.4 for ; Fri, 20 May 2011 11:45:23 -0700 (PDT) Sender: Richard Henderson Message-ID: <4DD6B6C2.7070803@twiddle.net> Date: Fri, 20 May 2011 11:45:22 -0700 From: Richard Henderson MIME-Version: 1.0 References: <898222ebb06df066cad8c5286bee65319e46789a.1305889001.git.batuzovk@ispras.ru> In-Reply-To: <898222ebb06df066cad8c5286bee65319e46789a.1305889001.git.batuzovk@ispras.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/6] Do constant folding for boolean operations. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirill Batuzov Cc: mj.mccormack@samsung.com, qemu-devel@nongnu.org, zhur@ispras.ru On 05/20/2011 05:39 AM, Kirill Batuzov wrote: > + case INDEX_op_or_i32: > + case INDEX_op_and_i32: > +#if TCG_TARGET_REG_BITS == 64 > + case INDEX_op_and_i64: > + case INDEX_op_or_i64: > +#endif > + if (args[1] == args[2]) { > + if (args[1] == args[0]) { > + args += 3; > + gen_opc_buf[op_index] = INDEX_op_nop; > + } else { I do wonder if it would be better to split this sort of optimization out into a different function. You're applying identity sorts of functions here, where you're not doing it for other operations, such as x + 0. Indeed, I'll argue that 0+x is more likely to happen than x|x, given that the 0 value could have been relocation filled in by the linker. Consider @hi16 and @lo16 relocation pairs when the symbol happens to be linked into the low 64k of the address space. r~