From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Bottomley Subject: Re: [patch V3] lib: GCD: add binary GCD algorithm Date: Thu, 28 Apr 2016 10:22:50 -0700 Message-ID: <1461864170.2307.19.camel@HansenPartnership.com> References: <1461843824-19853-1-git-send-email-zengzhaoxiu@163.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Zhaoxiu Zeng , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Yoshinori Sato , Geert Uytterhoeven , James Hogan , Michal Simek , Ralf Baechle , Ley Foon Tan , Jonas Bonn , "James E.J. Bottomley" , Helge Deller , Chen Liqin , Lennox Wu , Rich Felker , "David S. Miller" , linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, uclinux-h8-devel@lists.sourceforge.jp, linux-m68k@lists.linux-m68k.org, linux-metag@vger.kernel.org, linu To: zengzhaoxiu@163.com, akpm@linux-foundation.org, linux@horizon.com, peterz@infradead.org Return-path: In-Reply-To: <1461843824-19853-1-git-send-email-zengzhaoxiu@163.com> List-ID: List-Id: linux-parisc.vger.kernel.org On Thu, 2016-04-28 at 19:43 +0800, zengzhaoxiu@163.com wrote: > From: Zhaoxiu Zeng > > Because some architectures (alpha, armv6, etc.) don't provide > hardware division, the mod operation is slow! Binary GCD algorithm > uses simple arithmetic operations, it replaces division with > arithmetic shifts, comparisons, and subtractions. > > I have compiled successfully with x86_64_defconfig and > i386_defconfig. What's the reason for wanting to optimize this and thus have to maintain (and test) two separate code paths, which is a significant expense? As far as I can see, gcd() is mosly used in finding optimal clocks for operations, which is usually done at start of day and not time critical. James