(rb_cstr_to_inum): Invoke bigsq instead of bigmul0.
(bigsq): Re-implemented.
(bigmul0): Invoke bigsq if two arguments are identical.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
SIZEOF_BDIGITS is added.
(bary_mul_precheck): Reduce comparisons.
(bary_mul): Invoke bary_sq_fast or bary_mul1 if the bignum size is
small.
(bigfixize): Resize the argument bignum here.
(bignorm): Don't call bigtrunc after bigfixize.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Based on patch by Juanito Fatas [Fixes GH-360]
https://github.com/ruby/ruby/pull/360
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(nlz32): Use __builtin_clz or __builtin_clzl if possible.
(nlz64): Use __builtin_clzl or __builtin_clzll if possible.
(nlz128): Use __builtin_clzll if possible.
* configure.in: Check __builtin_clz, __builtin_clzl and
__builtin_clzll.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
__builtin_bswap64.
* internal.h (swap32): Use the configure result for the condition to
use __builtin_bswap32.
(swap64): Use the configure result for the condition to use
__builtin_bswap64.
* bignum.c (ones): Use the configure result for the condition to use
__builtin_popcountl.
(bary_unpack_internal): Use appropriate types for swap argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigsub_core): Removed.
(bigsub): Don't compare before subtraction. Just subtract and
get the two's complement if the subtraction causes a borrow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
big_lshift and big_rshift are merged.
(big_shift2): New function.
(big_lshift): Use big_shift3.
(big_rshift): Ditto.
(check_shiftdown): Removed.
(rb_big_lshift): Use big_shift2 and big_shift3.
(rb_big_rshift): Ditto.
(big_lshift): Removed.
(big_rshift): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigrsh_bang): Ditto.
(bigmul1_toom3): Use bary_small_lshift and bary_small_rshift.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(mulfunc_t): New type.
(bary_mul_toom3_start): Renamed from bary_mul.
(bary_mul_karatsuba_start): Renamed from bary_mul.
(bary_mul_balance_with_mulfunc): Renamed from bary_mul_balance and
new argument, mulfunc, is added.
(rb_big_mul_balance): Invoke bary_mul_balance_with_mulfunc with
bary_mul_toom3_start.
(bary_mul_karatsuba): Invoke bary_mul_karatsuba_start instead of
bary_mul.
(bary_mul_precheck): Extracted from bary_mul.
(bary_mul_karatsuba_branch): Extracted from bary_mul.
(bary_mul_karatsuba_start): New function to call bary_mul_precheck
and bary_mul_karatsuba_branch.
(bary_mul_toom3_branch): Extracted from bary_mul.
(bary_mul_toom3_start): New function to call bary_mul_precheck and
bary_mul_toom3_branch.
(bary_mul): Just call bary_mul_toom3_start.
Arguments for work memory are removed.
(rb_cstr_to_inum): Follow the bary_mul change.
(bigmul0): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_add_one): Replaced by the implementation of bary_plus_one.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (maxpow_in_bdigit_dbl, maxpow_in_bdigit): select by
preprocessor conditions to reduce dead code and suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e