[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1417190476-18066-3-git-send-email-linux@rasmusvillemoes.dk>
Date: Fri, 28 Nov 2014 17:01:05 +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 2/7] 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@...musvillemoes.dk>
---
lib/bitmap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 2332115..9250c3f 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -127,13 +127,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;
}
--
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