On Thu, Apr 5, 2018 at 12:24 AM, Peter Zijlstra <pet...@infradead.org> wrote: > > I always assumed BT was a more expensive instruction than AND with > immediate.
Oh, absolutely. That's why we do all those "depending on immediate or not". The reason I brought that case up is that "test_bit()" and "set_bit()" do this "is it constant" test COMPLETELY DIFFERENTLY. The test_bit() one is arguably much more legible, and easier to understand. And it so happens that clang will see that it's constant because it's a macro (well, unless that macro is then used in an inline function). The set_bit() pattern looks completely different, and doesn't have that abstraction of "constant_set_bit()" vs "variable_set_bit()", like test_bit() does. THAT was why I pointed it out - we do different things otherwise similar operations. Not because it would be odd that we do different things for the "constant bit number" vs "variable bit number". Linus