[Gmp-commit] /var/hg/gmp: Use __clz_tab[128] in count_trailing_zeros (C varia...

mercurial at gmplib.org mercurial at gmplib.org
Tue Mar 20 18:32:37 CET 2012


details:   /var/hg/gmp/rev/ddf83948a04b
changeset: 14776:ddf83948a04b
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Tue Mar 20 18:32:27 2012 +0100
description:
Use __clz_tab[128] in count_trailing_zeros (C variant).

diffstat:

 ChangeLog    |   5 +++++
 longlong.h   |  10 +++++-----
 mp_clz_tab.c |   5 +++--
 3 files changed, 13 insertions(+), 7 deletions(-)

diffs (61 lines):

diff -r 5a954e695686 -r ddf83948a04b ChangeLog
--- a/ChangeLog	Tue Mar 20 14:00:21 2012 +0100
+++ b/ChangeLog	Tue Mar 20 18:32:27 2012 +0100
@@ -1,3 +1,8 @@
+2012-03-19 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mp_clz_tab.c: Add __clz_tab[128].
+	* longlong.h (count_trailing_zeros): Use it in pure C variant.
+
 2012-03-20  Torbjorn Granlund  <tege at gmplib.org>
 
 	* configure.in (x86 fat_path): Add many missing directories.
diff -r 5a954e695686 -r ddf83948a04b longlong.h
--- a/longlong.h	Tue Mar 20 14:00:21 2012 +0100
+++ b/longlong.h	Tue Mar 20 18:32:27 2012 +0100
@@ -2051,7 +2051,7 @@
 #endif
 
 #ifdef COUNT_LEADING_ZEROS_NEED_CLZ_TAB
-extern const unsigned char __GMP_DECLSPEC __clz_tab[128];
+extern const unsigned char __GMP_DECLSPEC __clz_tab[129];
 #endif
 
 #if !defined (count_trailing_zeros)
@@ -2074,14 +2074,14 @@
     UWtype __ctz_x = (x);						\
     int __ctz_c;							\
 									\
-    if (LIKELY ((__ctz_x & 0x7f) != 0))					\
+    if (LIKELY ((__ctz_x & 0xff) != 0))					\
       (count) = __clz_tab[__ctz_x & -__ctz_x] - 2;			\
     else								\
       {									\
-	for (__ctz_c = 5; __ctz_c <= W_TYPE_SIZE; __ctz_c += 7)		\
+	for (__ctz_c = 8 - 2; __ctz_c < W_TYPE_SIZE - 2; __ctz_c += 8)	\
 	  {								\
-	    __ctz_x >>= 7;						\
-	    if (LIKELY ((__ctz_x & 0x7f) != 0))				\
+	    __ctz_x >>= 8;						\
+	    if (LIKELY ((__ctz_x & 0xff) != 0))				\
 	      break;							\
 	  }								\
 									\
diff -r 5a954e695686 -r ddf83948a04b mp_clz_tab.c
--- a/mp_clz_tab.c	Tue Mar 20 14:00:21 2012 +0100
+++ b/mp_clz_tab.c	Tue Mar 20 18:32:27 2012 +0100
@@ -27,11 +27,12 @@
 
 #ifdef COUNT_LEADING_ZEROS_NEED_CLZ_TAB
 const
-unsigned char __clz_tab[128] =
+unsigned char __clz_tab[129] =
 {
   1,2,3,3,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-  8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
+  8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+  9
 };
 #endif


More information about the gmp-commit mailing list