From: Mark H Weaver <mhw@netris.org>
To: nisse@lysator.liu.se (Niels Möller)
Cc: 10519@debbugs.gnu.org, "Ludovic Courtès" <ludo@gnu.org>,
"Torbjorn Granlund" <tg@gmplib.org>
Subject: bug#10519: guile and (mini-)gmp
Date: Wed, 27 Mar 2013 13:00:03 -0400 [thread overview]
Message-ID: <87obe46ang.fsf@tines.lan> (raw)
In-Reply-To: <nnboa6mv6l.fsf@stalhein.lysator.liu.se> ("Niels \=\?utf-8\?Q\?M\?\= \=\?utf-8\?Q\?\=C3\=B6ller\=22's\?\= message of "Tue, 26 Mar 2013 09:17:38 +0100")
Hi Niels,
nisse@lysator.liu.se (Niels Möller) 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 == 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
next prev parent reply other threads:[~2013-03-27 17:00 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-15 21:22 bug#10519: guile and (mini-)gmp Niels Möller
2012-01-16 10:19 ` Mark H Weaver
2012-01-16 14:06 ` Niels Möller
2012-01-16 19:21 ` Mark H Weaver
2012-01-28 9:49 ` Niels Möller
2012-01-28 10:10 ` Mark H Weaver
2012-07-22 9:04 ` Ludovic Courtès
2012-02-03 13:40 ` Andy Wingo
2012-02-03 19:56 ` Niels Möller
2012-02-03 20:01 ` Torbjorn Granlund
2012-02-04 22:46 ` Ludovic Courtès
2012-07-22 9:00 ` Ludovic Courtès
2012-07-22 23:17 ` Niels Möller
2012-08-10 21:51 ` Ludovic Courtès
2012-08-11 9:37 ` Niels Möller
2012-08-11 19:46 ` Ludovic Courtès
2012-08-11 21:50 ` Niels Möller
2012-08-11 22:48 ` Ludovic Courtès
2013-03-02 20:04 ` Andy Wingo
2013-03-02 20:58 ` Mark H Weaver
2013-03-05 19:09 ` Mark H Weaver
2013-03-18 0:01 ` Mark H Weaver
2013-03-18 9:19 ` Ludovic Courtès
2013-03-26 8:17 ` Niels Möller
2013-03-27 17:00 ` Mark H Weaver [this message]
2016-10-27 12:29 ` Niels Möller
2016-11-10 19:56 ` Andy Wingo
2013-03-02 21:45 ` Niels Möller
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87obe46ang.fsf@tines.lan \
--to=mhw@netris.org \
--cc=10519@debbugs.gnu.org \
--cc=ludo@gnu.org \
--cc=nisse@lysator.liu.se \
--cc=tg@gmplib.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).