From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=45686 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6yYt-0008P9-3p for qemu-devel@nongnu.org; Tue, 05 Apr 2011 01:12:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q6yYs-0002Gs-3v for qemu-devel@nongnu.org; Tue, 05 Apr 2011 01:12:19 -0400 Received: from ozlabs.org ([203.10.76.45]:54621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q6yYr-0002GQ-MF for qemu-devel@nongnu.org; Tue, 05 Apr 2011 01:12:18 -0400 From: David Gibson Date: Tue, 5 Apr 2011 15:12:11 +1000 Message-Id: <1301980331-21179-4-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1301980331-21179-1-git-send-email-david@gibson.dropbear.id.au> References: <1301980331-21179-1-git-send-email-david@gibson.dropbear.id.au> Subject: [Qemu-devel] [PATCH 3/3] Use existing helper function to implement popcntd instruction List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: agraf@suse.de, qemu-devel@nongnu.org The recent patches adding partial support for POWER7 cpu emulation included implementing the popcntd instruction. The support for this was open coded, but host-utils.h already included a function implementing an equivalent population count function, which uses a gcc builtin (which can use special host instructions) if available. This patch makes the popcntd implementation use the existing, potentially faster, implementation. Signed-off-by: David Gibson --- target-ppc/op_helper.c | 14 +------------- 1 files changed, 1 insertions(+), 13 deletions(-) diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c index b1b883d..5882bec 100644 --- a/target-ppc/op_helper.c +++ b/target-ppc/op_helper.c @@ -528,19 +528,7 @@ target_ulong helper_popcntw (target_ulong val) target_ulong helper_popcntd (target_ulong val) { - val = (val & 0x5555555555555555ULL) + ((val >> 1) & - 0x5555555555555555ULL); - val = (val & 0x3333333333333333ULL) + ((val >> 2) & - 0x3333333333333333ULL); - val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & - 0x0f0f0f0f0f0f0f0fULL); - val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & - 0x00ff00ff00ff00ffULL); - val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & - 0x0000ffff0000ffffULL); - val = (val & 0x00000000ffffffffULL) + ((val >> 32) & - 0x00000000ffffffffULL); - return val; + return ctpop64(val); } #else target_ulong helper_popcntb (target_ulong val) -- 1.7.1