From: David Gibson <david@gibson.dropbear.id.au>
To: agraf@suse.de, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] Use existing helper function to implement popcntd instruction
Date: Tue, 5 Apr 2011 15:12:11 +1000 [thread overview]
Message-ID: <1301980331-21179-4-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1301980331-21179-1-git-send-email-david@gibson.dropbear.id.au>
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 <david@gibson.dropbear.id.au>
---
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
prev parent reply other threads:[~2011-04-05 5:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-05 5:12 [Qemu-devel] [0/3] pSeries machine improvements David Gibson
2011-04-05 5:12 ` [Qemu-devel] [PATCH 1/3] pseries: Abolish envs array David Gibson
2011-04-05 8:05 ` [Qemu-devel] " Alexander Graf
2011-04-05 13:16 ` David Gibson
2011-04-05 13:55 ` Alexander Graf
2011-04-05 5:12 ` [Qemu-devel] [PATCH 2/3] Delay creation of pseries device tree until reset David Gibson
2011-04-05 5:12 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1301980331-21179-4-git-send-email-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).