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 <[email protected]>
---
 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to