Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d8a6b2a authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds
Browse files

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: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2fbad299
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -129,13 +129,13 @@ void __bitmap_shift_right(unsigned long *dst, const unsigned long *src,
			upper = src[off + k + 1];
			upper = src[off + k + 1];
			if (off + k + 1 == lim - 1 && left)
			if (off + k + 1 == lim - 1 && left)
				upper &= mask;
				upper &= mask;
			upper <<= (BITS_PER_LONG - rem);
		}
		}
		lower = src[off + k];
		lower = src[off + k];
		if (left && off + k == lim - 1)
		if (left && off + k == lim - 1)
			lower &= mask;
			lower &= mask;
		dst[k] = lower >> rem;
		lower >>= rem;
		if (rem)
		dst[k] = lower | upper;
			dst[k] |= upper << (BITS_PER_LONG - rem);
		if (left && k == lim - 1)
		if (left && k == lim - 1)
			dst[k] &= mask;
			dst[k] &= mask;
	}
	}