Skip to content

Commit

Permalink
Replace "mov %eax, %ecx; shl $1, $ecx" by "lea (%eax,%eax), %ecx"
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Aug 27, 2020
1 parent bb1d031 commit 972041d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -3972,11 +3972,19 @@ static int zend_jit_math_long_long(dasm_State **Dst,
IS_SIGNED_32BIT(Z_LVAL_P(Z_ZV(op1_addr))) &&
is_power_of_two(Z_LVAL_P(Z_ZV(op1_addr)))))) {
if (Z_MODE(op2_addr) == IS_CONST_ZVAL) {
| GET_ZVAL_LVAL result_reg, op1_addr
| shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
if (Z_MODE(op1_addr) == IS_REG && Z_LVAL_P(Z_ZV(op2_addr)) == 2) {
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))+Ra(Z_REG(op1_addr))]
} else {
| GET_ZVAL_LVAL result_reg, op1_addr
| shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
}
} else {
| GET_ZVAL_LVAL result_reg, op2_addr
| shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op1_addr)))
if (Z_MODE(op2_addr) == IS_REG && Z_LVAL_P(Z_ZV(op1_addr)) == 2) {
| lea Ra(result_reg), [Ra(Z_REG(op2_addr))+Ra(Z_REG(op2_addr))]
} else {
| GET_ZVAL_LVAL result_reg, op2_addr
| shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op1_addr)))
}
}
} else if (opcode == ZEND_DIV &&
(Z_MODE(op2_addr) == IS_CONST_ZVAL &&
Expand Down Expand Up @@ -4593,6 +4601,8 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
| SAVE_VALID_OPLINE opline, r0
| jmp ->negative_shift
}
} else if (Z_MODE(op1_addr) == IS_REG && op2_lval == 1) {
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))+Ra(Z_REG(op1_addr))]
} else {
| GET_ZVAL_LVAL result_reg, op1_addr
| shl Ra(result_reg), op2_lval
Expand Down

0 comments on commit 972041d

Please sign in to comment.