From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: nisse@lysator.liu.se (Niels =?UTF-8?Q?M=C3=B6ller?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#10519: guile and (mini-)gmp Date: Tue, 26 Mar 2013 09:17:38 +0100 Message-ID: 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=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1364285935 19315 80.91.229.3 (26 Mar 2013 08:18:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Mar 2013 08:18:55 +0000 (UTC) Cc: 10519@debbugs.gnu.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= , Torbjorn Granlund To: Mark H Weaver Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Mar 26 09:19:21 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 1UKP6A-0007yl-QB for guile-bugs@m.gmane.org; Tue, 26 Mar 2013 09:19:15 +0100 Original-Received: from localhost ([::1]:57990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKP5m-0001yq-MG for guile-bugs@m.gmane.org; Tue, 26 Mar 2013 04:18:50 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKP5i-0001uj-Jd for bug-guile@gnu.org; Tue, 26 Mar 2013 04:18:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKP5g-0007K9-T6 for bug-guile@gnu.org; Tue, 26 Mar 2013 04:18:46 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKP5g-0007K0-QI for bug-guile@gnu.org; Tue, 26 Mar 2013 04:18:44 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UKP7t-0002Op-UM for bug-guile@gnu.org; Tue, 26 Mar 2013 04:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: nisse@lysator.liu.se (Niels =?UTF-8?Q?M=C3=B6ller?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 26 Mar 2013 08:21: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.13642860059151 (code B ref 10519); Tue, 26 Mar 2013 08:21:01 +0000 Original-Received: (at 10519) by debbugs.gnu.org; 26 Mar 2013 08:20:05 +0000 Original-Received: from localhost ([127.0.0.1]:45548 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKP6y-0002NX-OT for submit@debbugs.gnu.org; Tue, 26 Mar 2013 04:20:05 -0400 Original-Received: from mail.lysator.liu.se ([130.236.254.3]:56112) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKP6t-0002My-QL for 10519@debbugs.gnu.org; Tue, 26 Mar 2013 04:20:02 -0400 Original-Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id EF35240005; Tue, 26 Mar 2013 09:17:40 +0100 (CET) Original-Received: from stalhein.lysator.liu.se (stalhein.lysator.liu.se [IPv6:2001:6b0:17:f0a0::cc]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPS id 6E1D240002; Tue, 26 Mar 2013 09:17:40 +0100 (CET) Original-Received: from stalhein.lysator.liu.se (localhost [127.0.0.1]) by stalhein.lysator.liu.se (8.14.4+Sun/8.14.4) with ESMTP id r2Q8HeiT013205; Tue, 26 Mar 2013 09:17:40 +0100 (MET) Original-Received: (from nisse@localhost) by stalhein.lysator.liu.se (8.14.4+Sun/8.14.4/Submit) id r2Q8HdO0013204; Tue, 26 Mar 2013 09:17:39 +0100 (MET) X-Authentication-Warning: stalhein.lysator.liu.se: nisse set sender to nisse@lysator.liu.se using -f In-Reply-To: <87620ph8yu.fsf@tines.lan> (Mark H. Weaver's message of "Sun, 17 Mar 2013 20:01:29 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (usg-unix-v) X-Virus-Scanned: ClamAV using ClamSMTP 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:7009 Archived-At: Mark H Weaver writes: > FYI, I've pushed patches to Guile's git repository (stable-2.0 branch) > which eliminate the known obstacles to mini-gmp integration. Out of curiosity, I had a quick look at the patches as posted to the guile devel list. 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. Regards, /Niels --=20 Niels M=F6ller. PGP-encrypted email is preferred. Keyid C0B98E26. Internet email is subject to wholesale government surveillance.