summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2015-02-14 01:36:05 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 08:21:35 +0300
commit9d8a6b2a02c5fae53d47bfffaabd5f12bb6ec2c0 (patch)
tree83b3b1366c55f3de296379435c4429a4b68e0cd7
parent2fbad29917c9852fa018d572cd3d43a13465d0f8 (diff)
downloadlinux-9d8a6b2a02c5fae53d47bfffaabd5f12bb6ec2c0.tar.xz
lib: bitmap: eliminate branch in __bitmap_shift_right
We can shift the bits from lower and upper into place before assembling dst[k]; moving the shift of upper 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.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 45e7d14ebdfd..a7a8bc02892d 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -129,13 +129,13 @@ void __bitmap_shift_right(unsigned long *dst, const unsigned long *src,
upper = src[off + k + 1];
if (off + k + 1 == lim - 1 && left)
upper &= mask;
+ upper <<= (BITS_PER_LONG - rem);
}
lower = src[off + k];
if (left && off + k == lim - 1)
lower &= mask;
- dst[k] = lower >> rem;
- if (rem)
- dst[k] |= upper << (BITS_PER_LONG - rem);
+ lower >>= rem;
+ dst[k] = lower | upper;
if (left && k == lim - 1)
dst[k] &= mask;
}