Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763069AbZFMP1r (ORCPT ); Sat, 13 Jun 2009 11:27:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755055AbZFMP1j (ORCPT ); Sat, 13 Jun 2009 11:27:39 -0400 Received: from earthlight.etchedpixels.co.uk ([81.2.110.250]:47795 "EHLO www.etchedpixels.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752338AbZFMP1j (ORCPT ); Sat, 13 Jun 2009 11:27:39 -0400 Date: Sat, 13 Jun 2009 16:28:02 +0100 From: Alan Cox To: James Cloos Cc: linux-kernel@vger.kernel.org, "Linux-MIPS" , Florian Fainelli , Andrew Morton , Takashi Iwai , Ralf Baechle Subject: Re: [PATCH 1/8] add lib/gcd.c Message-ID: <20090613162802.6c212505@lxorguk.ukuu.org.uk> In-Reply-To: References: <200906041615.10467.florian@openwrt.org> X-Mailer: Claws Mail 3.7.0 (GTK+ 2.14.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 640 Lines: 14 > Would the binary gcd algorithm not be a better fit for the kernel? > > It avoids division, using only shifts and subtraction: Time them both and see. I suspect on a lot of processors the divide based one now wins. We also have fls() and ffs() which may mean some platforms can implement the first two loops even better. Could well be the shift based one is better for some processors only. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/