Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1693654

Re: [PATCH] lib/int_sqrt.c: Optimize square root function

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH] lib/int_sqrt.c: Optimize square root function
Date 2017-07-21 14:20 +0200
Message-ID <u5F4u-4Ir-7@gated-at.bofh.it> (permalink)
References (4 earlier) <u5hOy-6De-7@gated-at.bofh.it> <u5owG-2Da-19@gated-at.bofh.it> <u5sgW-4Zm-21@gated-at.bofh.it> <u5t3j-5yN-3@gated-at.bofh.it> <u5EBs-4jK-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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?

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] lib/int_sqrt.c: Optimize square root function Peter Zijlstra <peterz@infradead.org> - 2017-07-20 13:30 +0200
  Re: [PATCH] lib/int_sqrt.c: Optimize square root function Joe Perches <joe@perches.com> - 2017-07-20 14:00 +0200
    Re: [PATCH] lib/int_sqrt.c: Optimize square root function Peter Zijlstra <peterz@infradead.org> - 2017-07-20 16:20 +0200
  Re: [PATCH] lib/int_sqrt.c: Optimize square root function Peter Zijlstra <peterz@infradead.org> - 2017-07-20 17:30 +0200
  Re: [PATCH] lib/int_sqrt.c: Optimize square root function Linus Torvalds <torvalds@linux-foundation.org> - 2017-07-20 20:40 +0200
    Re: [PATCH] lib/int_sqrt.c: Optimize square root function Peter Zijlstra <peterz@infradead.org> - 2017-07-21 00:40 +0200
      Re: [PATCH] lib/int_sqrt.c: Optimize square root function Linus Torvalds <torvalds@linux-foundation.org> - 2017-07-21 01:30 +0200
        Re: [PATCH] lib/int_sqrt.c: Optimize square root function Peter Zijlstra <peterz@infradead.org> - 2017-07-21 13:50 +0200
          Re: [PATCH] lib/int_sqrt.c: Optimize square root function Joe Perches <joe@perches.com> - 2017-07-21 14:20 +0200
            Re: [PATCH] lib/int_sqrt.c: Optimize square root function Peter Zijlstra <peterz@infradead.org> - 2017-07-21 15:30 +0200
              Re: [PATCH] lib/int_sqrt.c: Optimize square root function Peter Zijlstra <peterz@infradead.org> - 2017-07-21 15:40 +0200

csiph-web