qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Aurelien Jarno <aurelien@aurel32.net>
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 10:58:31 +0200	[thread overview]
Message-ID: <53A3F7B7.2030206@redhat.com> (raw)
In-Reply-To: <20140620084806.GB13901@ohm.rr44.fr>

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.

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.

This actually makes sense, and then there's no need to change anything.

Paolo

  reply	other threads:[~2014-06-20  8:58 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 [this message]
2014-06-20  9:43       ` 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=53A3F7B7.2030206@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aurelien@aurel32.net \
    --cc=corentin.chary@gmail.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 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).