* 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
This commit is contained in:
akr 2013-07-15 00:46:00 +00:00
Родитель 5f2080048e
Коммит 508669b6da
3 изменённых файлов: 11 добавлений и 66 удалений

Просмотреть файл

@ -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):

Просмотреть файл

@ -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)

Просмотреть файл

@ -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)])