From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Andrew Morton <akpm@linux-foundation.org>, Jan Kara <jack@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/7] lib: bitmap: Eliminate branch in __bitmap_shift_right
Date: Fri, 28 Nov 2014 17:01:05 +0100 [thread overview]
Message-ID: <1417190476-18066-3-git-send-email-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <1417190476-18066-1-git-send-email-linux@rasmusvillemoes.dk>
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>
---
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
next prev parent reply other threads:[~2014-11-28 16:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-28 16:01 [PATCH 0/7] lib: bitmap: Simplify bitmap_shift_{left,right} Rasmus Villemoes
2014-11-28 16:01 ` [PATCH 1/7] lib: bitmap: Change bitmap_shift_right to take unsigned parameters Rasmus Villemoes
2014-11-28 16:01 ` Rasmus Villemoes [this message]
2014-11-28 16:01 ` [PATCH 3/7] lib: bitmap: Remove redundant code from __bitmap_shift_right Rasmus Villemoes
2014-11-28 16:01 ` [PATCH 4/7] lib: bitmap: Yet another simplification in __bitmap_shift_right Rasmus Villemoes
2014-11-28 16:01 ` [PATCH 5/7] lib: bitmap: Change bitmap_shift_left to take unsigned parameters Rasmus Villemoes
2014-11-28 16:01 ` [PATCH 6/7] lib: bitmap: Eliminate branch in __bitmap_shift_left Rasmus Villemoes
2014-11-28 16:01 ` [PATCH 7/7] lib: bitmap: Remove redundant code from __bitmap_shift_left Rasmus Villemoes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417190476-18066-3-git-send-email-linux@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®