From: "Laurent Desnogues" <laurent.desnogues@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [5592] target-ppc: optimize popcntb
Date: Sat, 1 Nov 2008 13:29:06 +0100 [thread overview]
Message-ID: <761ea48b0811010529w50904850h41028a811609fefc@mail.gmail.com> (raw)
In-Reply-To: <E1Kw4l8-0001Qe-9E@cvs.savannah.gnu.org>
On Sat, Nov 1, 2008 at 1:54 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> Revision: 5592
> http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5592
[...]
> Modified: trunk/target-ppc/op_helper.c
> ===================================================================
> --- trunk/target-ppc/op_helper.c 2008-11-01 00:54:23 UTC (rev 5591)
> +++ trunk/target-ppc/op_helper.c 2008-11-01 00:54:33 UTC (rev 5592)
> @@ -222,25 +222,19 @@
>
> target_ulong helper_popcntb (target_ulong val)
> {
> - uint32_t ret;
> - int i;
> -
> - ret = 0;
> - for (i = 0; i < 32; i += 8)
> - ret |= ctpop8((val >> i) & 0xFF) << i;
> - return ret;
> + val = (val & 0x55555555) + ((val >> 1) & 0x55555555);
> + val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
> + val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f);
> + return val;
> }
>
> #if defined(TARGET_PPC64)
> target_ulong helper_popcntb_64 (target_ulong val)
> {
> - uint64_t ret;
> - int i;
> -
> - ret = 0;
> - for (i = 0; i < 64; i += 8)
> - ret |= ctpop8((val >> i) & 0xFF) << i;
> - return ret;
> + val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);
> + val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL);
> + val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL);
> + return val;
> }
> #endif
Wouldn't it make sense to use builtin's as is done in host-utils.h?
Laurent
next prev parent reply other threads:[~2008-11-01 12:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-01 0:54 [Qemu-devel] [5592] target-ppc: optimize popcntb Aurelien Jarno
2008-11-01 12:29 ` Laurent Desnogues [this message]
2008-11-01 12:35 ` Laurent Desnogues
2008-11-01 13:57 ` andrzej zaborowski
2008-11-01 14:34 ` Laurent Desnogues
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=761ea48b0811010529w50904850h41028a811609fefc@mail.gmail.com \
--to=laurent.desnogues@gmail.com \
--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).