|
From: | Paolo Bonzini |
Subject: | Re: [Qemu-devel] [PATCH] bitops: provide an inline implementation of find_first_bit |
Date: | Fri, 20 Jun 2014 10:58:31 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |