summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-15 00:46:00 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-15 00:46:00 +0000
commit508669b6daa416a3585affc0b7363aaa8b2c6e43 (patch)
treebd9554a7f037a13e24f089ac6ed7d6b1fc5eb14d
parent5f2080048e6bf76b647bec00c4b9cb1c7ec79ab2 (diff)
* bignum.c (power_cache_get_power): Use bitsize insteadof ceil_log2.
(ones): Removed. (next_pow2): Removed. (floor_log2): Removed. (ceil_log2): Removed. * configure.in (__builtin_popcountl): Don't check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--bignum.c66
-rw-r--r--configure.in1
3 files changed, 11 insertions, 66 deletions
diff --git a/ChangeLog b/ChangeLog
index 0ea6e738524..41ce0b8fddd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Jul 15 09:39:07 2013 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (power_cache_get_power): Use bitsize insteadof ceil_log2.
+ (ones): Removed.
+ (next_pow2): Removed.
+ (floor_log2): Removed.
+ (ceil_log2): Removed.
+
+ * configure.in (__builtin_popcountl): Don't check.
+
Mon Jul 15 02:47:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* localeinit.c (rb_locale_charmap, Init_enc_set_filesystem_encoding):
diff --git a/bignum.c b/bignum.c
index ec99f7be6e7..fa8477e8219 100644
--- a/bignum.c
+++ b/bignum.c
@@ -3304,70 +3304,6 @@ big_rshift(VALUE x, unsigned long shift)
return big_shift3(x, 0, s1, s2);
}
-static inline int
-ones(register unsigned long x)
-{
-#ifdef HAVE_BUILTIN___BUILTIN_POPCOUNTL
- return __builtin_popcountl(x);
-#else
-# if SIZEOF_LONG == 8
-# define MASK_55 0x5555555555555555UL
-# define MASK_33 0x3333333333333333UL
-# define MASK_0f 0x0f0f0f0f0f0f0f0fUL
-# else
-# define MASK_55 0x55555555UL
-# define MASK_33 0x33333333UL
-# define MASK_0f 0x0f0f0f0fUL
-# endif
- x -= (x >> 1) & MASK_55;
- x = ((x >> 2) & MASK_33) + (x & MASK_33);
- x = ((x >> 4) + x) & MASK_0f;
- x += (x >> 8);
- x += (x >> 16);
-# if SIZEOF_LONG == 8
- x += (x >> 32);
-# endif
- return (int)(x & 0x7f);
-# undef MASK_0f
-# undef MASK_33
-# undef MASK_55
-#endif
-}
-
-static inline unsigned long
-next_pow2(register unsigned long x)
-{
- x |= x >> 1;
- x |= x >> 2;
- x |= x >> 4;
- x |= x >> 8;
- x |= x >> 16;
-#if SIZEOF_LONG == 8
- x |= x >> 32;
-#endif
- return x + 1;
-}
-
-static inline int
-floor_log2(register unsigned long x)
-{
- x |= x >> 1;
- x |= x >> 2;
- x |= x >> 4;
- x |= x >> 8;
- x |= x >> 16;
-#if SIZEOF_LONG == 8
- x |= x >> 32;
-#endif
- return (int)ones(x) - 1;
-}
-
-static inline int
-ceil_log2(register unsigned long x)
-{
- return floor_log2(x) + !POW2_P(x);
-}
-
#define LOG2_KARATSUBA_DIGITS 7
#define KARATSUBA_DIGITS (1L<<LOG2_KARATSUBA_DIGITS)
#define MAX_BIG2STR_TABLE_ENTRIES 64
@@ -3407,7 +3343,7 @@ power_cache_get_power(int base, long n1, long* m1)
if (n1 <= KARATSUBA_DIGITS)
rb_bug("n1 > KARATSUBA_DIGITS");
- m = ceil_log2(n1);
+ m = bitsize(n1-1); /* ceil(log2(n1)) */
if (m1) *m1 = 1 << m;
i = m - LOG2_KARATSUBA_DIGITS;
if (i >= MAX_BIG2STR_TABLE_ENTRIES)
diff --git a/configure.in b/configure.in
index adc465a4274..739d3370726 100644
--- a/configure.in
+++ b/configure.in
@@ -1847,7 +1847,6 @@ AC_CACHE_CHECK([for $1], AS_TR_SH(rb_cv_builtin_$1),
if test "${AS_TR_SH(rb_cv_builtin_$1)}" != no; then
AC_DEFINE(AS_TR_CPP(HAVE_BUILTIN_$1))
fi])
-RUBY_CHECK_BUILTIN_FUNC(__builtin_popcountl, [__builtin_popcountl(0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap32, [__builtin_bswap32(0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap64, [__builtin_bswap64(0)])