From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#10519: guile and (mini-)gmp Date: Wed, 27 Mar 2013 13:00:03 -0400 Message-ID: <87obe46ang.fsf@tines.lan> References: <874np05fwz.fsf@gnu.org> <874noawh4r.fsf@gnu.org> <87zk61qkjh.fsf@gnu.org> <87lihlqc3u.fsf@gnu.org> <87txotbmag.fsf@pobox.com> <878v65frid.fsf@tines.lan> <874ngpeka0.fsf@tines.lan> <87620ph8yu.fsf@tines.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1364403647 21410 80.91.229.3 (27 Mar 2013 17:00:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Mar 2013 17:00:47 +0000 (UTC) Cc: 10519@debbugs.gnu.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= , Torbjorn Granlund To: nisse@lysator.liu.se (Niels =?UTF-8?Q?M=C3=B6ller?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Mar 27 18:01:13 2013 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UKtiq-0004ZF-Kf for guile-bugs@m.gmane.org; Wed, 27 Mar 2013 18:01:12 +0100 Original-Received: from localhost ([::1]:44142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKtiS-0005YT-GN for guile-bugs@m.gmane.org; Wed, 27 Mar 2013 13:00:48 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKtiM-0005Wy-0p for bug-guile@gnu.org; Wed, 27 Mar 2013 13:00:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKtiK-0006wW-Id for bug-guile@gnu.org; Wed, 27 Mar 2013 13:00:41 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKtiK-0006wP-Fg for bug-guile@gnu.org; Wed, 27 Mar 2013 13:00:40 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UKtkb-0003TH-PD for bug-guile@gnu.org; Wed, 27 Mar 2013 13:03:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 27 Mar 2013 17:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10519 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 10519-submit@debbugs.gnu.org id=B10519.136440376913305 (code B ref 10519); Wed, 27 Mar 2013 17:03:01 +0000 Original-Received: (at 10519) by debbugs.gnu.org; 27 Mar 2013 17:02:49 +0000 Original-Received: from localhost ([127.0.0.1]:47904 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKtkO-0003SV-U6 for submit@debbugs.gnu.org; Wed, 27 Mar 2013 13:02:49 -0400 Original-Received: from world.peace.net ([96.39.62.75]:49324) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKtkM-0003SO-Q6 for 10519@debbugs.gnu.org; Wed, 27 Mar 2013 13:02:48 -0400 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UKtht-00034G-Lz; Wed, 27 Mar 2013 13:00:13 -0400 In-Reply-To: ("Niels \=\?utf-8\?Q\?M\?\= \=\?utf-8\?Q\?\=C3\=B6ller\=22's\?\= message of "Tue, 26 Mar 2013 09:17:38 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7013 Archived-At: Hi Niels, nisse@lysator.liu.se (Niels M=C3=B6ller) writes: > For the small integer gcd code, you may want to have a look at the > tricks used in > http://gmplib.org:8000/gmp/file/304af17b9ccc/mpn/generic/gcd_1.c, the > code under GCD_1_METHOD =3D=3D 2 > > 1. Shift out the least significant bit of both a and b (they're always > one). Maybe you don't need this of you have some extra bits already > (signed types, or some bits reserved for type info). > > 2. Then, the sign bit of a - b correctly gives the result of the > comparison a < b. Constructing a mask from this difference is then a > simple right shift (if >> on a signed int is not an arithmetic right > shift, you need shift and a negation). > > 3. Use this bit mask when forming the absolute value |a - b|, and when > swapping values around, to avoid unpredictable branches which > typically are quite expensive. Excellent tricks! Thanks for sharing. I'll try to find the time to apply these ideas soon, but probably not before 2.0.8 -- there are too many more important things to do for that, and not enough time. Regards, Mark