[ruby-cvs:64950] shyouhei:r57784 (trunk): use HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW

shyouhei at ruby-lang.org shyouhei at ruby-lang.org
Mon Mar 6 15:04:52 JST 2017


shyouhei	2017-03-06 15:04:52 +0900 (Mon, 06 Mar 2017)

  New Revision: 57784

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57784

  Log:
    use HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW
    
    We already check for __builtin_mul_overflow in configure but never
    actually referred it before.  Why not call it if available, because
    that should render supposedly-optimial assembly outputs.
    
    Optionally if __builtin_mul_overflow_p is available, which is the case
    for recent GCC, use that to detect fixnum overflow.  This is much
    faster than the previous.  On my machine generated assembly of
    numeric.c:int_pow reduces from 480 to 448 bytes, according to nm(1).
    Also on my machine, following script boosts from 7.819 to 6.929 sec.
    
    time ./miniruby -e 'i=0; while i < 30_000_000 do i += 1; 7 ** 23; end'
    
    Signed-off-by: Urabe, Shyouhei <shyouhei at ruby-lang.org>

  Modified files:
    trunk/configure.in
    trunk/internal.h
    trunk/process.c


More information about the ruby-cvs mailing list