Received: from eggs.gnu.org ([2001:4830:134:3::10]:55484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZF3KP-00013M-GA for qemu-devel@nongnu.org; Tue, 14 Jul 2015 12:45:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZF3KL-00007P-AK for qemu-devel@nongnu.org; Tue, 14 Jul 2015 12:45:09 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:100::1]:41782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZF3KL-00005t-5W for qemu-devel@nongnu.org; Tue, 14 Jul 2015 12:45:05 -0400 Date: Tue, 14 Jul 2015 18:45:03 +0200 From: Aurelien Jarno Message-ID: <20150714164503.GB7569@aurel32.net> References: <1436888717-8122-1-git-send-email-aurelien@aurel32.net> <1436888717-8122-3-git-send-email-aurelien@aurel32.net> <55A53633.1050106@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55A53633.1050106@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/2] target-mips: simplify LWL/LDL mask generation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Leon Alrae , =?iso-8859-15?Q?Herv=E9?= Poussineau , qemu-devel@nongnu.org On 2015-07-14 18:17, Paolo Bonzini wrote: > > > On 14/07/2015 17:45, Aurelien Jarno wrote: > > The LWL/LDL instructions mask the GPR with a mask depending on the > > address alignement. It is currently computed by doing: > > > > mask = 0x7fffffffffffffffull >> (t1 ^ 63) > > > > It's simpler to generate it by doing: > > > > mask = (1 << t1) - 1 > > Using ~(-1 << t1) may let you use an ANDN instruction, and is also the > same number of instructions on x86. > Indeed thanks for the hint. The generated code has the same size, but is one instruction less: mov 0x88(%rsp),%r10 shlx %r10,%rbx,%rbx - mov $0x1,%r11d + mov $0xffffffffffffffff,%r11 shlx %r10,%r11,%r11 - dec %r11 mov 0x18(%r14),%r10 - and %r11,%r10 + andn %r10,%r11,%r10 or %r10,%rbx movslq %ebx,%rbx I'll send a new version of the patch. -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://www.aurel32.net