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 via email to