From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTDem-0004Af-Dd for qemu-devel@nongnu.org; Tue, 09 Feb 2016 14:09:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTDeh-0008S4-Ba for qemu-devel@nongnu.org; Tue, 09 Feb 2016 14:09:00 -0500 Received: from mail-pa0-x243.google.com ([2607:f8b0:400e:c03::243]:35950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTDeh-0008S0-4K for qemu-devel@nongnu.org; Tue, 09 Feb 2016 14:08:55 -0500 Received: by mail-pa0-x243.google.com with SMTP id sv5so4228205pab.3 for ; Tue, 09 Feb 2016 11:08:55 -0800 (PST) Sender: Richard Henderson References: <1436429849-18052-1-git-send-email-rth@twiddle.net> <1436429849-18052-6-git-send-email-rth@twiddle.net> <56B9E971.9070509@redhat.com> From: Richard Henderson Message-ID: <56BA393F.40607@twiddle.net> Date: Wed, 10 Feb 2016 06:08:47 +1100 MIME-Version: 1.0 In-Reply-To: <56B9E971.9070509@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 05/14] target-i386: Enable control registers for MPX List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: ehabkost@redhat.com On 02/10/2016 12:28 AM, Paolo Bonzini wrote: > On 09/07/2015 10:17, Richard Henderson wrote: >> + /* Disallow enabling only half of MPX. */ >> + if ((mask ^ (mask * (XSTATE_BNDCSR / XSTATE_BNDREGS))) & XSTATE_BNDCSR) { > > I'm refreshing patches 1-4 to add PKE support, and this caught my eye... > > What about just > > if (!!(mask & XSTATE_BNDCSR) != !!(mask & XSTATE_BNDREGS)) > > ? Hmph. Missed optimization for your version. It is a bit more readable though, I admit... r~ void bar(); void foo(unsigned mask) { if ((mask ^ (mask * 4)) & 8) { bar(); } } void baz(unsigned mask) { if (!!(mask & 8) != !!(mask & 2)) { bar(); } } foo: leal 0(,%rdi,4), %eax xorl %eax, %edi andl $8, %edi jne .L4 ... baz: movl %edi, %eax shrl %edi shrl $3, %eax andl $1, %edi andl $1, %eax cmpb %dil, %al je .L5 ... clang_baz: movl %edi, %eax shrl $3, %eax shrl %edi xorl %eax, %edi testb $1, %dil jne .LBB1_2