qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Stuart Brady <sdbrady@ntlworld.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target-arm: use clz32() instead of a for loop
Date: Fri, 23 Oct 2009 09:04:53 +0200	[thread overview]
Message-ID: <4AE15595.8050709@aurel32.net> (raw)
In-Reply-To: <20091023003417.GA31360@miranda.arrow>

Stuart Brady a écrit :
> On Thu, Oct 15, 2009 at 11:14:52PM +0200, Aurelien Jarno wrote:
>> @@ -394,10 +395,7 @@ uint32_t HELPER(uxtb16)(uint32_t x)
>>  
>>  uint32_t HELPER(clz)(uint32_t x)
>>  {
>> -    int count;
>> -    for (count = 32; x; count--)
>> -        x >>= 1;
>> -    return count;
>> +    return clz32(x);
>>  }
>>  
>>  int32_t HELPER(sdiv)(int32_t num, int32_t den)
> 
> Just a quick note that the implementation of clz, ctz and popcnt is
> still listed in the TCG TODO list.  The last time I looked, I noticed
> that quite a few architectures have clz/ctz instructions:
> 
>    http://lkml.indiana.edu/hypermail/linux/kernel/0601.3/1683.html

OTOH, a dump shows that those instruction are not used than often, so I
am not sure it worth implementing it.

> For those that don't, I think a combination the following two hacks at
> http://graphics.stanford.edu/~seander/bithacks.html could be used:

The best is probably to use an helper in that case, calling clz32(x).

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  reply	other threads:[~2009-10-23  7:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-15 21:14 [Qemu-devel] [PATCH] target-arm: use clz32() instead of a for loop Aurelien Jarno
2009-10-18 14:21 ` Laurent Desnogues
2009-10-23  0:34 ` Stuart Brady
2009-10-23  7:04   ` Aurelien Jarno [this message]
2009-10-23 12:47     ` Stuart Brady
2009-10-23 14:38       ` Aurelien Jarno

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=4AE15595.8050709@aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    --cc=sdbrady@ntlworld.com \
    /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).