Re: [GIT PULL] x86/build changes for v4.17

From: Linus Torvalds
Date: Thu Apr 05 2018 - 12:43:48 EST


On Thu, Apr 5, 2018 at 12:24 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> 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