[ruby-cvs:64959] naruse:r57793 (trunk): Use ADD instead of MUL

naruse at ruby-lang.org naruse at ruby-lang.org
Tue Mar 7 12:35:48 JST 2017

naruse	2017-03-07 12:35:47 +0900 (Tue, 07 Mar 2017)

  New Revision: 57793


    Use ADD instead of MUL
    * On recent CPUs, 2-operand MUL's latency is 3 cycle but ADD is 1 cycle.
    * clang Optimizes `MUL rax,2` into `ADD rax,rax` but gcc7 doesn't.
    * LONG2FIX is compiled into `lea r14,[r15+r15*1+0x1]`; this is 1cycle
      and run in parallel if the branch prediction is correct.
    * Note that old (RB_POSFIXABLE(f) && RB_NEGFIXABLE(f)) is usually uses
      following instructions.
      * movabs rax,0x4000000000000000
      * add    rax,rdi
      * js
      It needs large immediate and Macro-Fusion is not applied.
      ADD and JO is much smaller though it is also Macro-Fusion unfriendly.

  Modified files:

More information about the ruby-cvs mailing list