From: Aurelien Jarno <aurelien@aurel32.net>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, Corentin Chary <corentin.chary@gmail.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] bitops: provide an inline implementation of find_first_bit
Date: Fri, 20 Jun 2014 11:43:55 +0200 [thread overview]
Message-ID: <20140620094355.GA12011@ohm.rr44.fr> (raw)
In-Reply-To: <53A3F7B7.2030206@redhat.com>
On Fri, Jun 20, 2014 at 10:58:31AM +0200, Paolo Bonzini wrote:
> Il 20/06/2014 10:48, Aurelien Jarno ha scritto:
> >In practice on x86_64, this function takes 27 instructions in the
> >general case, and 18 instructions in the fixed case, even for big
> >sizes. I therefore think that checking if the size is constant is a good
> >idea, but we should not make any test on the size itself and trust the
> >compiler to correctly decide if the loop should be unrolled or not.
>
> But if the size is large enough that the compiler will (likely) not
> unroll the function, then it should pay off to use the more
> optimized code in find_next_bit.
The point there is that given find_next_bit is a generalized version of
find_first_bit, it is actually slower. I originally noticed that by
running profiling tools and noticing this function appeared relatively
high for what it is supposed to do.
> This of course is unless you expect find_first_bit to return a small
> value and not be used in a loop; and dually expect find_next_bit's
> usage to be more like walking sparser bitmaps in a loop.
I think that's the point. In the TCG case, this is used to map the
temp allocation to answer the question "give me a free temp". That said
people might invent new usages.
> This actually makes sense, and then there's no need to change anything.
>
> Paolo
>
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://www.aurel32.net
prev parent reply other threads:[~2014-06-20 9:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-22 11:32 [Qemu-devel] [PATCH] bitops: provide an inline implementation of find_first_bit Aurelien Jarno
2013-12-22 17:04 ` Richard Henderson
2014-06-19 8:36 ` Paolo Bonzini
2014-06-20 8:48 ` Aurelien Jarno
2014-06-20 8:58 ` Paolo Bonzini
2014-06-20 9:43 ` Aurelien Jarno [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=20140620094355.GA12011@ohm.rr44.fr \
--to=aurelien@aurel32.net \
--cc=corentin.chary@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.