[Gmp-commit] /var/hg/gmp: 10 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Thu May 15 16:59:25 UTC 2014
details: /var/hg/gmp/rev/30cd6db7f95a
changeset: 16380:30cd6db7f95a
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:17:02 2014 +0200
description:
Remove redundant ChangeLog entry
details: /var/hg/gmp/rev/c274e0832b47
changeset: 16381:c274e0832b47
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:21:56 2014 +0200
description:
mini-gmp/mini-gmp.c: always use the same while syntax.
details: /var/hg/gmp/rev/430795ab1cbc
changeset: 16382:430795ab1cbc
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:23:29 2014 +0200
description:
mini-gmp/mini-gmp.c (mpn_mul): micro-optimisations
details: /var/hg/gmp/rev/598aabb07816
changeset: 16383:598aabb07816
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:24:39 2014 +0200
description:
mini-gmp/mini-gmp.c: remove a few branches
details: /var/hg/gmp/rev/58c28fea4850
changeset: 16384:58c28fea4850
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:26:24 2014 +0200
description:
mini-gmp/mini-gmp.c: use mpz_roinit_n wherever appropriate
details: /var/hg/gmp/rev/9519c4a2cf77
changeset: 16385:9519c4a2cf77
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:27:39 2014 +0200
description:
ChangeLog
details: /var/hg/gmp/rev/55bd25eb17bd
changeset: 16386:55bd25eb17bd
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:51:26 2014 +0200
description:
gen-fib.c: use mpz_setbit, gen-psqr.c: skip even numbers when looking for primes
details: /var/hg/gmp/rev/5f7968be4510
changeset: 16387:5f7968be4510
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:52:20 2014 +0200
description:
ChangeLog
details: /var/hg/gmp/rev/3ba9bb0b4e19
changeset: 16388:3ba9bb0b4e19
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:58:25 2014 +0200
description:
mpn/generic/invert.c: avoid a branch
details: /var/hg/gmp/rev/f62c69d14a37
changeset: 16389:f62c69d14a37
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 15 18:59:16 2014 +0200
description:
ChangeLog
diffstat:
ChangeLog | 13 +++++++++----
gen-fib.c | 4 ++--
gen-psqr.c | 7 +++----
mini-gmp/mini-gmp.c | 37 +++++++++++++------------------------
mpn/generic/invert.c | 7 +++++--
5 files changed, 32 insertions(+), 36 deletions(-)
diffs (217 lines):
diff -r 8a70dd4c020c -r f62c69d14a37 ChangeLog
--- a/ChangeLog Thu May 08 00:33:09 2014 +0200
+++ b/ChangeLog Thu May 15 18:59:16 2014 +0200
@@ -1,3 +1,12 @@
+2014-05-15 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * mini-gmp/mini-gmp.c: Micro-optimisations.
+
+ * gen-fib.c: Use mpz_setbit.
+ * gen-psqr.c: Skip even numbers when looking for primes.
+
+ * mpn/generic/invert.c: Avoid a branch.
+
2014-05-08 Marc Glisse <marc.glisse at inria.fr>
* gmpxx.h (std::common_type): Remove partial specialization for two
@@ -8,10 +17,6 @@
* doc/gmp.texi (mpz_invert): Clarify behavior in the zero ring.
-2014-04-13 Marco Bodrato <bodrato at mail.dm.unipi.it>
-
- * doc/gmp.texi (mpz_invert): rop possibly is 0 (iif |op2| = 1).
-
2014-04-04 Marc Glisse <marc.glisse at inria.fr>
* longlong.h (i386): Add comment about "cc" clobber.
diff -r 8a70dd4c020c -r f62c69d14a37 gen-fib.c
--- a/gen-fib.c Thu May 08 00:33:09 2014 +0200
+++ b/gen-fib.c Thu May 15 18:59:16 2014 +0200
@@ -40,8 +40,8 @@
mpz_t limit, l;
int falloc, i;
- mpz_init_set_ui (limit, 1L);
- mpz_mul_2exp (limit, limit, numb_bits);
+ mpz_init2 (limit, numb_bits);
+ mpz_setbit (limit, numb_bits);
/* fib(2n) > 2^n, so use 2n as a limit for the table size */
falloc = 2 * numb_bits;
diff -r 8a70dd4c020c -r f62c69d14a37 gen-psqr.c
--- a/gen-psqr.c Thu May 08 00:33:09 2014 +0200
+++ b/gen-psqr.c Thu May 15 18:59:16 2014 +0200
@@ -174,8 +174,7 @@
int
mul_2exp_mod (int n, int p, int m)
{
- int i;
- for (i = 0; i < p; i++)
+ while (--p >= 0)
n = (2 * n) % m;
return n;
}
@@ -289,7 +288,7 @@
mpz_init (q);
mpz_init (r);
- for (i = 3; i <= max_divisor; i++)
+ for (i = 3; i <= max_divisor; i+=2)
{
if (! isprime (i))
continue;
@@ -341,7 +340,7 @@
/* one copy of each small prime */
mpz_set_ui (pp, 1L);
- for (i = 3; i <= max_divisor; i++)
+ for (i = 3; i <= max_divisor; i+=2)
{
if (! isprime (i))
continue;
diff -r 8a70dd4c020c -r f62c69d14a37 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c Thu May 08 00:33:09 2014 +0200
+++ b/mini-gmp/mini-gmp.c Thu May 15 18:59:16 2014 +0200
@@ -346,7 +346,7 @@
void
mpn_copyd (mp_ptr d, mp_srcptr s, mp_size_t n)
{
- while (n-- > 0)
+ while (--n >= 0)
d[n] = s[n];
}
@@ -578,17 +578,16 @@
way. */
rp[un] = mpn_mul_1 (rp, up, un, vp[0]);
- rp += 1, vp += 1, vn -= 1;
/* Now accumulate the product of up[] and the next higher limb from
vp[]. */
- while (vn >= 1)
+ while (--vn >= 1)
{
+ rp += 1, vp += 1;
rp[un] = mpn_addmul_1 (rp, up, un, vp[0]);
- rp += 1, vp += 1, vn -= 1;
}
- return rp[un - 1];
+ return rp[un];
}
void
@@ -876,7 +875,7 @@
d = inv->d1;
di = inv->di;
- while (nn-- > 0)
+ while (--nn >= 0)
{
mp_limb_t q;
@@ -1475,14 +1474,12 @@
{
mp_size_t us = u->_mp_size;
- if (us == 0)
- return 1;
- else if (us == 1)
+ if (us == 1)
return u->_mp_d[0] < GMP_LIMB_HIGHBIT;
else if (us == -1)
return u->_mp_d[0] <= GMP_LIMB_HIGHBIT;
else
- return 0;
+ return (us == 0);
}
int
@@ -1796,18 +1793,14 @@
void
mpz_abs (mpz_t r, const mpz_t u)
{
- if (r != u)
- mpz_set (r, u);
-
+ mpz_set (r, u);
r->_mp_size = GMP_ABS (r->_mp_size);
}
void
mpz_neg (mpz_t r, const mpz_t u)
{
- if (r != u)
- mpz_set (r, u);
-
+ mpz_set (r, u);
r->_mp_size = -r->_mp_size;
}
@@ -3074,9 +3067,7 @@
mpz_ui_pow_ui (mpz_t r, unsigned long blimb, unsigned long e)
{
mpz_t b;
- mpz_init_set_ui (b, blimb);
- mpz_pow_ui (r, b, e);
- mpz_clear (b);
+ mpz_pow_ui (r, mpz_roinit_n (b, &blimb, 1), e);
}
void
@@ -3148,7 +3139,7 @@
}
mpz_init_set_ui (tr, 1);
- while (en-- > 0)
+ while (--en >= 0)
{
mp_limb_t w = e->_mp_d[en];
mp_limb_t bit;
@@ -3188,9 +3179,7 @@
mpz_powm_ui (mpz_t r, const mpz_t b, unsigned long elimb, const mpz_t m)
{
mpz_t e;
- mpz_init_set_ui (e, elimb);
- mpz_powm (r, b, e, m);
- mpz_clear (e);
+ mpz_powm (r, b, mpz_roinit_n (e, &elimb, 1), m);
}
/* x=trunc(y^(1/z)), r=y-x^z */
@@ -3504,7 +3493,7 @@
must be complemented. */
if (shift > 0 && (w << (GMP_LIMB_BITS - shift)) > 0)
return bit ^ 1;
- while (limb_index-- > 0)
+ while (--limb_index >= 0)
if (d->_mp_d[limb_index] > 0)
return bit ^ 1;
}
diff -r 8a70dd4c020c -r f62c69d14a37 mpn/generic/invert.c
--- a/mpn/generic/invert.c Thu May 08 00:33:09 2014 +0200
+++ b/mpn/generic/invert.c Thu May 15 18:59:16 2014 +0200
@@ -6,7 +6,7 @@
SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GMP RELEASE.
-Copyright (C) 2007, 2009, 2010, 2012 Free Software Foundation, Inc.
+Copyright (C) 2007, 2009, 2010, 2012, 2014 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -60,8 +60,11 @@
mp_ptr xp;
xp = scratch; /* 2 * n limbs */
- for (i = n - 1; i >= 0; i--)
+ /* n > 1 here */
+ i = n - 1;
+ do
xp[i] = GMP_NUMB_MAX;
+ while (--i >= 0);
mpn_com (xp + n, dp, n);
if (n == 2) {
mpn_divrem_2 (ip, 0, xp, 4, dp);
More information about the gmp-commit
mailing list