From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z02iU-0002yO-65 for qemu-devel@nongnu.org; Wed, 03 Jun 2015 03:04:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z02iO-0002Lk-S6 for qemu-devel@nongnu.org; Wed, 03 Jun 2015 03:03:58 -0400 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]:35036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z02iO-0002L2-M7 for qemu-devel@nongnu.org; Wed, 03 Jun 2015 03:03:52 -0400 Received: by wgme6 with SMTP id e6so920513wgm.2 for ; Wed, 03 Jun 2015 00:03:52 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <556EA6D4.701@redhat.com> Date: Wed, 03 Jun 2015 09:03:48 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1432214398-14990-1-git-send-email-pbonzini@redhat.com> <556E8300.1010108@twiddle.net> In-Reply-To: <556E8300.1010108@twiddle.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] exec: optimize phys_page_set_level List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson , qemu-devel@nongnu.org Cc: stefanha@redhat.com, mst@redhat.com On 03/06/2015 06:30, Richard Henderson wrote: > On 05/21/2015 06:19 AM, Paolo Bonzini wrote: >> memcpy is faster than struct assignment, which copies each bitfield >> individually. Arguably a compiler bug, but memcpy is super-special >> cased anyway so what could go wrong? > > The compiler has the option of doing the copy either way. Any way to > actually show that the small memcpy is faster? That's one of those > things where I'm sure there's a cost calculation that said per member > was better. Because the struct size is 32 bits, it's a no brainer that full copy is faster. However, SRA gets in the way, and causes the struct assignment to be compiled as two separate bitfield assignment. Later GCC passes don't have the means to merge them again. I filed https://gcc.gnu.org/PR66391 about this and CCed Martin Jambor. Paolo