Re: [PATCH] Bitmap: Optimized division operation to shift operation

From: Joe Perches
Date: Wed Apr 15 2020 - 03:50:12 EST


On Wed, 2020-04-15 at 15:27 +0800, Wang Qing wrote:
> On some processors, the / operate will call the compiler`s div lib,
> which is low efficient. Bitmap is performance sensitive, We can
> replace the / operation with shift.

Seems more like bad compilers than useful code changes
unless you can specify what compilers and what processors.

> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
[]
> @@ -337,7 +337,7 @@ static inline int bitmap_equal(const unsigned long *src1,
> return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
> if (__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
> IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
> - return !memcmp(src1, src2, nbits / 8);
> + return !memcmp(src1, src2, nbits >> 3);