[ruby-cvs:61263] naruse:r54102 (trunk): * bignum.c (big2str_2bdigits): reduce div instruction.

naruse at ruby-lang.org naruse at ruby-lang.org
Mon Mar 14 19:14:49 JST 2016


naruse	2016-03-14 19:14:48 +0900 (Mon, 14 Mar 2016)

  New Revision: 54102

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

  Log:
    * bignum.c (big2str_2bdigits): reduce div instruction.
    
    Fix the code so that C compiler unify div instructions of `%` and `/`.
    
    Before:
      4291b0:       48 89 f0                mov    %rsi,%rax
      4291b3:       31 d2                   xor    %edx,%edx
      4291b5:       48 83 ef 01             sub    $0x1,%rdi
      4291b9:       48 f7 f1                div    %rcx  # <---- !
      4291bc:       41 0f b6 04 11          movzbl (%r9,%rdx,1),%eax
      4291c1:       31 d2                   xor    %edx,%edx
      4291c3:       41 88 04 38             mov    %al,(%r8,%rdi,1)
      4291c7:       48 63 4b 04             movslq 0x4(%rbx),%rcx
      4291cb:       48 89 f0                mov    %rsi,%rax
      4291ce:       48 f7 f1                div    %rcx  # <---- !
      4291d1:       48 89 c6                mov    %rax,%rsi
      4291d4:       48 85 ff                test   %rdi,%rdi
      4291d7:       75 d7                   jne    4291b0 <big2str_2bdigits+0x50>
      4291d9:       48 63 6b 10             movslq 0x10(%rbx),%rbp
      4291dd:       48 01 6b 20             add    %rbp,0x20(%rbx)
      4291e1:       48 8b 44 24 48          mov    0x48(%rsp),%rax
      4291e6:       64 48 33 04 25 28 00    xor    %fs:0x28,%rax
    
    After:
      4291b0:       48 63 73 04             movslq 0x4(%rbx),%rsi
      4291b4:       31 d2                   xor    %edx,%edx
      4291b6:       48 83 e9 01             sub    $0x1,%rcx
      4291ba:       48 f7 f6                div    %rsi  # <---- !
      4291bd:       41 0f b6 14 10          movzbl (%r8,%rdx,1),%edx
      4291c2:       88 14 0f                mov    %dl,(%rdi,%rcx,1)
      4291c5:       48 85 c9                test   %rcx,%rcx
      4291c8:       75 e6                   jne    4291b0 <big2str_2bdigits+0x50>
      4291ca:       48 63 6b 10             movslq 0x10(%rbx),%rbp
      4291ce:       48 01 6b 20             add    %rbp,0x20(%rbx)
      4291d2:       48 8b 44 24 48          mov    0x48(%rsp),%rax
      4291d7:       64 48 33 04 25 28 00    xor    %fs:0x28,%rax

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c


More information about the ruby-cvs mailing list