[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <874db8b91ff04001a8958f100a614ed8@AcuMS.aculab.com>
Date: Tue, 23 Nov 2021 10:42:45 +0000
From: David Laight <David.Laight@...LAB.COM>
To: "'Vaittinen, Matti'" <Matti.Vaittinen@...rohmeurope.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC: Matti Vaittinen <mazziesaccount@...il.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Jiri Kosina <trivial@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Yury Norov <yury.norov@...il.com>,
Kumar Kartikeya Dwivedi <memxor@...il.com>,
"Rasmus Villemoes" <linux@...musvillemoes.dk>,
Geert Uytterhoeven <geert+renesas@...der.be>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 1/4] bitops: Add single_bit_set()
From: Vaittinen, Matti
> Sent: 22 November 2021 13:19
>
> On 11/22/21 14:57, Andy Shevchenko wrote:
> > On Mon, Nov 22, 2021 at 12:42:21PM +0000, Vaittinen, Matti wrote:
> >> On 11/22/21 13:28, Andy Shevchenko wrote:
> >>> On Mon, Nov 22, 2021 at 01:03:25PM +0200, Matti Vaittinen wrote:
> >
> > What do you mean by this?
> >
> > hweight() will return you the number of the non-zero elements in the set.
>
> Exactly. The function I added did only check if given set of bits had
> only one bit set.
Checking for exactly one bit can use the (x & (x - 1)) check on
non-zero values - which may even be better on some cpus with a
popcnt instruction.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists