[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 2 Feb 2015 11:13:44 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Anshul Garg <aksgarg1989@...il.com>,
Davidlohr Bueso <dave@...olabs.net>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
anshul.g@...sung.com
Subject: Re: [PATCH] lib/int_sqrt.c: Optimize square root function
On Mon, Feb 2, 2015 at 11:00 AM, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> (I'm also not entirely sure what uses int_sqrt() that ends up being so
> performance-critical, so it would be good to document that too, since
> that probably also matters for the "what's the normal argument range"
> question..)
... it's also not entirely clear that we need a whole new loop. We
might just instead start off with a better guess for 'm' using some
calculation that might be doable with a single conditional move
instruction instead of a loop. Because I suspect that the inevitable
branch misprediction of a new loop is likely as expensive as a few
iterations through the core one.
IOW, instead of
m = 1UL << (BITS_PER_LONG - 2);
perhaps something like
m = 1UL << (BITS_PER_LONG/2- 2);
if (m < x)
m <<= BITS_PER_LONG/2;
(assuming gcc can change that code into a "cmov") might cut down the
"lots of empty loops" case in half for small values of 'x'.
There's probably some other better cheap initial guess value estimator.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists