Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753428AbdGUMPP (ORCPT ); Fri, 21 Jul 2017 08:15:15 -0400 Received: from smtprelay0024.hostedemail.com ([216.40.44.24]:60837 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750762AbdGUMPO (ORCPT ); Fri, 21 Jul 2017 08:15:14 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:541:599:960:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1537:1566:1593:1594:1711:1714:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3622:3868:3871:4321:5007:10004:10400:10848:11026:11473:11658:11914:12740:12760:12895:13069:13311:13357:13439:14659:14721:21080:21627:30054:30060:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: swing99_2d6c7065fb356 X-Filterd-Recvd-Size: 1917 Message-ID: <1500639310.14415.25.camel@perches.com> Subject: Re: [PATCH] lib/int_sqrt.c: Optimize square root function From: Joe Perches To: Peter Zijlstra , Linus Torvalds Cc: Anshul Garg , Davidlohr Bueso , Linux Kernel Mailing List , "anshul.g@samsung.com" , Thomas Gleixner , Ingo Molnar , Will Deacon Date: Fri, 21 Jul 2017 05:15:10 -0700 In-Reply-To: <20170721114039.dqip5wj2tha42mol@hirez.programming.kicks-ass.net> References: <1422897162-111998-1-git-send-email-aksgarg1989@gmail.com> <20170720112449.6xvc2ghaj3jh6w7l@hirez.programming.kicks-ass.net> <20170720223416.fxkgdtvuqwxxmf3y@hirez.programming.kicks-ass.net> <20170721114039.dqip5wj2tha42mol@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 316 Lines: 14 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?