[Gmp-commit] /var/hg/gmp: 8 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Jun 24 20:18:41 CEST 2012


details:   /var/hg/gmp/rev/198d3b4eecae
changeset: 15058:198d3b4eecae
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 24 19:56:32 2012 +0200
description:
configure.in (CALLING_CONVENTIONS_OBJS): Disable whit --disable-assembly.

details:   /var/hg/gmp/rev/24a2343ef5b1
changeset: 15059:24a2343ef5b1
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 24 19:57:29 2012 +0200
description:
mpz/oddfac_1.c: Use the ASSERT_CODE macro

details:   /var/hg/gmp/rev/5b66ec63b239
changeset: 15060:5b66ec63b239
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 24 19:58:20 2012 +0200
description:
gen-trialdivtab.c (mpz_log2): Use mpz_sizeinbase (., 2)

details:   /var/hg/gmp/rev/dca91817e163
changeset: 15061:dca91817e163
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 24 19:59:49 2012 +0200
description:
Replace MPN_SIZEINBASE_16 in gmp-impl.h with MPN_SIZEINBASE_2EXP from mpz/export.c

details:   /var/hg/gmp/rev/1e8b9156a4d5
changeset: 15062:1e8b9156a4d5
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 24 20:00:37 2012 +0200
description:
mpn/generic/sizeinbase.c: Use MPN_SIZEINBASE

details:   /var/hg/gmp/rev/d8aa9054f3c1
changeset: 15063:d8aa9054f3c1
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 24 20:01:48 2012 +0200
description:
Use MPN_SIZEINBASE_2EXP to count bits

details:   /var/hg/gmp/rev/dd933ce95d4f
changeset: 15064:dd933ce95d4f
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 24 20:03:55 2012 +0200
description:
mpn/generic/pow*.c: Use MPN_SIZEINBASE_2EXP, it's a nail-ready way to count bits.

details:   /var/hg/gmp/rev/99b3ed7de276
changeset: 15065:99b3ed7de276
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 24 20:11:18 2012 +0200
description:
mpn/generic/powm_sec.c: nail-ready.

diffstat:

 ChangeLog                |  20 ++++++++++++++++++++
 configure.in             |   6 +++++-
 gen-trialdivtab.c        |  17 ++---------------
 gmp-impl.h               |  30 +++++++++++-------------------
 mpn/generic/perfpow.c    |  11 +++++------
 mpn/generic/powlo.c      |   5 ++---
 mpn/generic/powm.c       |   5 ++---
 mpn/generic/powm_sec.c   |  14 ++++++--------
 mpn/generic/rootrem.c    |   6 ++----
 mpn/generic/sizeinbase.c |  33 +++++----------------------------
 mpz/export.c             |  13 -------------
 mpz/get_d_2exp.c         |   6 ++----
 mpz/nextprime.c          |   6 ++----
 mpz/oddfac_1.c           |   6 +++---
 14 files changed, 67 insertions(+), 111 deletions(-)

diffs (truncated from 439 to 300 lines):

diff -r 7bd7a74c3c0d -r 99b3ed7de276 ChangeLog
--- a/ChangeLog	Sat Jun 23 21:38:59 2012 +0200
+++ b/ChangeLog	Sun Jun 24 20:11:18 2012 +0200
@@ -1,3 +1,23 @@
+2012-06-24 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* configure.in (CALLING_CONVENTIONS_OBJS): Disable any use of
+	assembly code whit the --disable-assembly option.
+	* mpz/oddfac_1.c: Use the ASSERT_CODE macro.
+	* gen-trialdivtab.c (mpz_log2): Use mpz_sizeinbase (., 2).
+
+	* gmp-impl.h (MPN_SIZEINBASE_16): Replace with MPN_SIZEINBASE_2EXP
+	from mpz/export.c .
+	* mpz/export.c (MPN_SIZEINBASE_2EXP): Removed.
+	* mpn/generic/sizeinbase.c: Use MPN_SIZEINBASE.
+
+	* mpz/nextprime.c: Use MPN_SIZEINBASE_2EXP to count bits.
+	* mpn/generic/perfpow.c: Likewise.
+	* mpn/generic/rootrem.c: Likewise.
+	* mpz/get_d_2exp.c: Likewise.
+	* mpn/generic/powm_sec.c: Likewise, nailify.
+	* mpn/generic/powlo.c: Likewise.
+	* mpn/generic/powm.c: Likewise.
+
 2012-06-23  Marc Glisse  <marc.glisse at inria.fr>
 
 	* gmpxx.h (numeric_limits): Make content public.
diff -r 7bd7a74c3c0d -r 99b3ed7de276 configure.in
--- a/configure.in	Sat Jun 23 21:38:59 2012 +0200
+++ b/configure.in	Sun Jun 24 20:11:18 2012 +0200
@@ -2085,7 +2085,11 @@
   #
                     eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi1\"
   test -n "$tmp" || eval tmp=\"\$CALLING_CONVENTIONS_OBJS$abi2\"
-  CALLING_CONVENTIONS_OBJS="$tmp"
+  if test "$enable_assembly" = "yes"; then
+     CALLING_CONVENTIONS_OBJS="$tmp"
+  else
+     CALLING_CONVENTIONS_OBJS=""
+  fi
 
   if test -n "$CALLING_CONVENTIONS_OBJS"; then
     AC_DEFINE(HAVE_CALLING_CONVENTIONS,1,
diff -r 7bd7a74c3c0d -r 99b3ed7de276 gen-trialdivtab.c
--- a/gen-trialdivtab.c	Sat Jun 23 21:38:59 2012 +0200
+++ b/gen-trialdivtab.c	Sun Jun 24 20:11:18 2012 +0200
@@ -2,7 +2,7 @@
 
    Contributed to the GNU project by Torbjorn Granlund.
 
-Copyright 2009 Free Software Foundation, Inc.
+Copyright 2009, 2012 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -203,20 +203,7 @@
 unsigned long
 mpz_log2 (mpz_t x)
 {
-  mpz_t y;
-  unsigned long cnt;
-
-  mpz_init (y);
-  mpz_set (y, x);
-  cnt = 0;
-  while (mpz_sgn (y) != 0)
-    {
-      mpz_tdiv_q_2exp (y, y, 1);
-      cnt++;
-    }
-  mpz_clear (y);
-
-  return cnt;
+  return mpz_sgn (x) ? mpz_sizeinbase (x, 2) : 0;
 }
 
 void
diff -r 7bd7a74c3c0d -r 99b3ed7de276 gmp-impl.h
--- a/gmp-impl.h	Sat Jun 23 21:38:59 2012 +0200
+++ b/gmp-impl.h	Sun Jun 24 20:11:18 2012 +0200
@@ -2810,7 +2810,7 @@
 
 #define MPN_SIZEINBASE(result, ptr, size, base)				\
   do {									\
-    int	      __lb_base, __cnt;						\
+    int	   __lb_base, __cnt;						\
     size_t __totbits;							\
 									\
     ASSERT ((size) >= 0);						\
@@ -2838,26 +2838,18 @@
       }									\
   } while (0)
 
-/* eliminate mp_bases lookups for base==16 */
-#define MPN_SIZEINBASE_16(result, ptr, size)				\
-  do {									\
-    int	      __cnt;							\
-    mp_size_t __totbits;						\
-									\
-    ASSERT ((size) >= 0);						\
-									\
-    /* Special case for X == 0.  */					\
-    if ((size) == 0)							\
-      (result) = 1;							\
-    else								\
-      {									\
-	/* Calculate the total number of significant bits of X.  */	\
-	count_leading_zeros (__cnt, (ptr)[(size)-1]);			\
-	__totbits = (size_t) (size) * GMP_NUMB_BITS - (__cnt - GMP_NAIL_BITS);\
-	(result) = (__totbits + 4 - 1) / 4;				\
-      }									\
+#define MPN_SIZEINBASE_2EXP(result, ptr, size, base2exp)			\
+  do {										\
+    int          __cnt;								\
+    mp_bitcnt_t  __totbits;							\
+    ASSERT ((size) > 0);							\
+    ASSERT ((ptr)[(size)-1] != 0);						\
+    count_leading_zeros (__cnt, (ptr)[(size)-1]);				\
+    __totbits = (mp_bitcnt_t) (size) * GMP_NUMB_BITS - (__cnt - GMP_NAIL_BITS);	\
+    (result) = (__totbits + (base2exp)-1) / (base2exp);				\
   } while (0)
 
+
 /* bit count to limb count, rounding up */
 #define BITS_TO_LIMBS(n)  (((n) + (GMP_NUMB_BITS - 1)) / GMP_NUMB_BITS)
 
diff -r 7bd7a74c3c0d -r 99b3ed7de276 mpn/generic/perfpow.c
--- a/mpn/generic/perfpow.c	Sat Jun 23 21:38:59 2012 +0200
+++ b/mpn/generic/perfpow.c	Sun Jun 24 20:11:18 2012 +0200
@@ -2,7 +2,7 @@
 
    Contributed to the GNU project by Martin Boij.
 
-Copyright 2009, 2010 Free Software Foundation, Inc.
+Copyright 2009, 2010, 2012 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -40,7 +40,7 @@
 	    mp_ptr tp)
 {
   mp_limb_t *tp2;
-  mp_bitcnt_t y, z, count;
+  mp_bitcnt_t y, z;
   mp_size_t i, bn;
   int ans;
   mp_limb_t h, l;
@@ -69,8 +69,8 @@
      the logarithm of {xp,xn}, rather than using the index of the MSB.
   */
 
-  count_leading_zeros (count, xp[xn - 1]);
-  y = xn * GMP_LIMB_BITS - count - 1;  /* msb_index (xp, xn) */
+  MPN_SIZEINBASE_2EXP(y, xp, xn, 1);
+  y -= 1;  /* msb_index (xp, xn) */
 
   umul_ppmm (h, l, k, y);
   h -= l == 0;  l--;	/* two-limb decrement */
@@ -482,8 +482,7 @@
       while (factor != 0);
     }
 
-  count_leading_zeros (count, nc[ncn-1]);
-  count = GMP_LIMB_BITS * ncn - count;   /* log (nc) + 1 */
+  MPN_SIZEINBASE_2EXP(count, nc, ncn, 1);   /* log (nc) + 1 */
   d = (mp_limb_t) (count * logs[trial] + 1e-9) + 1;
   ans = perfpow (nc, ncn, d, g, count, neg);
 
diff -r 7bd7a74c3c0d -r 99b3ed7de276 mpn/generic/powlo.c
--- a/mpn/generic/powlo.c	Sat Jun 23 21:38:59 2012 +0200
+++ b/mpn/generic/powlo.c	Sun Jun 24 20:11:18 2012 +0200
@@ -1,6 +1,6 @@
 /* mpn_powlo -- Compute R = U^E mod B^n, where B is the limb base.
 
-Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2012 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -81,8 +81,7 @@
 
   TMP_MARK;
 
-  count_leading_zeros (cnt, ep[en - 1]);
-  ebi = (mp_bitcnt_t) en * GMP_LIMB_BITS - cnt;
+  MPN_SIZEINBASE_2EXP(ebi, ep, en, 1);
 
   windowsize = win_size (ebi);
 
diff -r 7bd7a74c3c0d -r 99b3ed7de276 mpn/generic/powm.c
--- a/mpn/generic/powm.c	Sat Jun 23 21:38:59 2012 +0200
+++ b/mpn/generic/powm.c	Sun Jun 24 20:11:18 2012 +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 GNU MP RELEASE.
 
-Copyright 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -173,8 +173,7 @@
 
   TMP_MARK;
 
-  count_leading_zeros (cnt, ep[en - 1]);
-  ebi = (mp_bitcnt_t) en * GMP_LIMB_BITS - cnt;
+  MPN_SIZEINBASE_2EXP(ebi, ep, en, 1);
 
 #if 0
   if (bn < n)
diff -r 7bd7a74c3c0d -r 99b3ed7de276 mpn/generic/powm_sec.c
--- a/mpn/generic/powm_sec.c	Sat Jun 23 21:38:59 2012 +0200
+++ b/mpn/generic/powm_sec.c	Sun Jun 24 20:11:18 2012 +0200
@@ -179,7 +179,7 @@
 #endif
 
 #define getbit(p,bi) \
-  ((p[(bi - 1) / GMP_LIMB_BITS] >> (bi - 1) % GMP_LIMB_BITS) & 1)
+  ((p[(bi - 1) / GMP_NUMB_BITS] >> (bi - 1) % GMP_NUMB_BITS) & 1)
 
 static inline mp_limb_t
 getbits (const mp_limb_t *p, mp_bitcnt_t bi, int nbits)
@@ -195,10 +195,10 @@
   else
     {
       bi -= nbits;			/* bit index of low bit to extract */
-      i = bi / GMP_LIMB_BITS;		/* word index of low bit to extract */
-      bi %= GMP_LIMB_BITS;		/* bit index in low word */
+      i = bi / GMP_NUMB_BITS;		/* word index of low bit to extract */
+      bi %= GMP_NUMB_BITS;		/* bit index in low word */
       r = p[i] >> bi;			/* extract (low) bits */
-      nbits_in_r = GMP_LIMB_BITS - bi;	/* number of bits now in r */
+      nbits_in_r = GMP_NUMB_BITS - bi;	/* number of bits now in r */
       if (nbits_in_r < nbits)		/* did we get enough bits? */
 	r += p[i + 1] << nbits_in_r;	/* prepend bits from higher word */
       return r & (((mp_limb_t ) 1 << nbits) - 1);
@@ -251,7 +251,6 @@
 	      mp_srcptr mp, mp_size_t n, mp_ptr tp)
 {
   mp_limb_t ip[2], *mip;
-  int cnt;
   mp_bitcnt_t ebi;
   int windowsize, this_windowsize;
   mp_limb_t expbits;
@@ -262,8 +261,7 @@
   ASSERT (en > 1 || (en == 1 && ep[0] > 0));
   ASSERT (n >= 1 && ((mp[0] & 1) != 0));
 
-  count_leading_zeros (cnt, ep[en - 1]);
-  ebi = (mp_bitcnt_t) en * GMP_LIMB_BITS - cnt;
+  MPN_SIZEINBASE_2EXP(ebi, ep, en, 1);
 
   windowsize = win_size (ebi);
 
@@ -418,7 +416,7 @@
      is 3n or 4n depending on if we use mpn_local_sqr or a native
      mpn_sqr_basecase.  We assume 4n always for now.) */
 
-  windowsize = win_size (en * GMP_LIMB_BITS); /* slight over-estimate of exp */
+  windowsize = win_size (en * GMP_NUMB_BITS); /* slight over-estimate of exp */
 
   /* The 2n term is due to pp[0] and pp[1] at the time of the 2nd redcify call,
      the 2bn + n + 1 term is due to redcify's own usage.  */
diff -r 7bd7a74c3c0d -r 99b3ed7de276 mpn/generic/rootrem.c
--- a/mpn/generic/rootrem.c	Sat Jun 23 21:38:59 2012 +0200
+++ b/mpn/generic/rootrem.c	Sun Jun 24 20:11:18 2012 +0200
@@ -8,7 +8,7 @@
    ONLY SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES.  IN FACT, IT'S ALMOST
    GUARANTEED THAT THEY'LL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
 
-Copyright 2002, 2005, 2009, 2010, 2011 Free Software Foundation, Inc.
+Copyright 2002, 2005, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -125,7 +125,6 @@
   mp_limb_t save, save2, cy;
   unsigned long int unb; /* number of significant bits of {up,un} */
   unsigned long int xnb; /* number of significant bits of the result */
-  unsigned int cnt;
   unsigned long b, kk;
   unsigned long sizes[GMP_NUMB_BITS + 1];
   int ni, i;
@@ -147,8 +146,7 @@
     }
   sp = rootp;
 
-  count_leading_zeros (cnt, up[un - 1]);
-  unb = un * GMP_NUMB_BITS - cnt + GMP_NAIL_BITS;
+  MPN_SIZEINBASE_2EXP(unb, up, un, 1);
   /* unb is the number of bits of the input U */
 
   xnb = (unb - 1) / k + 1;	/* ceil (unb / k) */
diff -r 7bd7a74c3c0d -r 99b3ed7de276 mpn/generic/sizeinbase.c
--- a/mpn/generic/sizeinbase.c	Sat Jun 23 21:38:59 2012 +0200
+++ b/mpn/generic/sizeinbase.c	Sun Jun 24 20:11:18 2012 +0200
@@ -4,7 +4,8 @@
    CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
    FUTURE GNU MP RELEASES.


More information about the gmp-commit mailing list