aboutsummaryrefslogtreecommitdiff
path: root/target-ppc
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2011-04-05 15:12:11 +1000
committerAlexander Graf <agraf@suse.de>2011-04-08 11:32:21 +0200
commit3601ff11732160e42d3174d2821d873cfcd52a59 (patch)
tree1225a922cec026062a27e2f6350d34e6efa272ca /target-ppc
parenta3467baa88c5bbb58834952980d2f2206aab4445 (diff)
Use existing helper function to implement popcntd instruction
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> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'target-ppc')
-rw-r--r--target-ppc/op_helper.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index b1b883d0a7..5882becbc9 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)