public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "George Spelvin" <linux@horizon.com>
To: peterz@infradead.org, zhaoxiu.zeng@gmail.com
Cc: akpm@linux-foundation.org, dhowells@redhat.com,
	jwboyer@redhat.com, linux-kernel@vger.kernel.org,
	linux@horizon.com, mingo@kernel.org, takahiro.akashi@linaro.org
Subject: Re: [PATCH 1/1] GCD: add binary GCD algorithm
Date: 15 Aug 2014 16:16:01 -0400	[thread overview]
Message-ID: <20140815201601.2497.qmail@ns.horizon.com> (raw)
In-Reply-To: <20140815135855.GG19379@twins.programming.kicks-ass.net>

> So I looked at wikipedia (I wasn't aware of this algorithm, clever
> though), and am still somewhat puzzled by your 'r'.
> 
> What's 'wrong' with their iterative version, or what's better about your
> 'r' stuff?

I need to look more carefully, but it looks nifty.

Basically, it's avoiding the usual issue of counting the lsbits to factor
out a power of 2.

Rather than taking out the common factors of 2 a bit at a time, to
reduce to the case where one is even and one is odd (i.e. ((a ^ b) & 1)
== 1), just find the low-order differing bit and use that instead of
"1" in the algorithm.  I.e. ((1 ^ b) & r) == r.

I have to see if there's a nicer way to arrange things, but it looks good.

What I'd like is a better way to automatically configure "divide is
slow" from an architecture.

  parent reply	other threads:[~2014-08-15 20:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-15 12:49 [PATCH 1/1] GCD: add binary GCD algorithm Zhaoxiu Zeng
2014-08-15 13:58 ` Peter Zijlstra
2014-08-15 16:41   ` zhaoxiu.zeng
2014-08-15 21:53     ` George Spelvin
2014-08-15 20:16   ` George Spelvin [this message]
2014-08-15 21:32     ` Peter Zijlstra
2014-08-22 21:31 ` Andrew Morton
2014-08-22 22:36   ` George Spelvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140815201601.2497.qmail@ns.horizon.com \
    --to=linux@horizon.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=jwboyer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=zhaoxiu.zeng@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox