[Top] [All Lists]

Re: [PATCH 1/8] add lib/gcd.c

To: James Cloos <>
Subject: Re: [PATCH 1/8] add lib/gcd.c
From: Alan Cox <>
Date: Sat, 13 Jun 2009 16:28:02 +0100
Cc:, "Linux-MIPS" <>, Florian Fainelli <>, Andrew Morton <>, Takashi Iwai <>, Ralf Baechle <>
In-reply-to: <>
Original-recipient: rfc822;
References: <> <>
> 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.

<Prev in Thread] Current Thread [Next in Thread>