[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1417190476-18066-7-git-send-email-linux@rasmusvillemoes.dk>
Date: Fri, 28 Nov 2014 17:01:09 +0100
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Andrew Morton <akpm@...ux-foundation.org>, Jan Kara <jack@...e.cz>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 6/7] 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@...musvillemoes.dk>
---
lib/bitmap.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 5edd71b..2362601 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;
}
--
2.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists