diff options
| author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-02-13 14:36:16 -0800 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-11 10:59:37 +0200 |
| commit | 2dc5a5a532a5992c47892b1f84ffbcfa4ff36786 (patch) | |
| tree | 74e9a84c3f96fd926afd4a7622a5b9e8cb4e6387 | |
| parent | fcfcf9fea498504630b0585a3c18add8c1c0fdc9 (diff) | |
lib: bitmap: eliminate branch in __bitmap_shift_left
We can shift the bits from lower and upper into place before assembling
dst[k + off]; moving the shift of lower into the branch where we already
know that rem is non-zero allows us to remove a conditional.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | lib/bitmap.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index d67b88a6a..ef4a8a992 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -167,15 +167,14 @@ void __bitmap_shift_left(unsigned long *dst, const unsigned long *src, * word below and make them the bottom rem bits of result. */ if (rem && k > 0) - lower = src[k - 1]; + lower = src[k - 1] >> (BITS_PER_LONG - rem); else lower = 0; upper = src[k]; if (left && k == lim - 1) upper &= (1UL << left) - 1; - dst[k + off] = upper << rem; - if (rem) - dst[k + off] |= lower >> (BITS_PER_LONG - rem); + upper <<= rem; + dst[k + off] = lower | upper; if (left && k + off == lim - 1) dst[k + off] &= (1UL << left) - 1; } |
