Re: [PATCH] lib/int_sqrt.c: Optimize square root function
From: Joe Perches
Date: Fri Jul 21 2017 - 08:15:18 EST
On Fri, 2017-07-21 at 13:40 +0200, Peter Zijlstra wrote:
> @@ -21,7 +22,11 @@ unsigned long int_sqrt(unsigned long x)
> if (x <= 1)
> return x;
>
> - m = 1UL << (BITS_PER_LONG - 2);
> + m = 1UL << (__fls(x) & ~1U);
> +
> + while (m > x)
> + m >>= 2;
while (m > x) ?
Belt and suspenders if __fls is broken?