Re: [PATCH 08/22] bitops: introduce MANY_BITS() macro

From: Rasmus Villemoes
Date: Wed May 11 2022 - 06:59:24 EST


On 10/05/2022 21.11, Yury Norov wrote:

> Another thing is that despite __attribute__(const), gcc sometimes doesn't
> recognize it as constant expression,

An ICE, Integer Constant Expression, is a C language thing.
__attribute__(const) has nothing to do with that, and no use of that
attribute is ever gonna convince gcc to treat an expression containing a
function call as an ICE [C++ is of course a whole different story].

The __attribute__(const) on a static inline function is utterly
pointless, the compiler can certainly see for itself that the function
has no side effects and that the expression can be CSE'ed.

All that aside, please drop that MANY_BITS thing. It will not make any
code any easier to read (MANY, is that four or five? or is it "more than
half the bit width"?). The n&(n-1) pattern is a well-known idiom, I
expect anybody hacking on an OS kernel to recognize

Rasmus