Skip to content

Commit 972041d

Browse files
committed
Replace "mov %eax, %ecx; shl $1, $ecx" by "lea (%eax,%eax), %ecx"
1 parent bb1d031 commit 972041d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,11 +3972,19 @@ static int zend_jit_math_long_long(dasm_State **Dst,
39723972
IS_SIGNED_32BIT(Z_LVAL_P(Z_ZV(op1_addr))) &&
39733973
is_power_of_two(Z_LVAL_P(Z_ZV(op1_addr)))))) {
39743974
if (Z_MODE(op2_addr) == IS_CONST_ZVAL) {
3975-
| GET_ZVAL_LVAL result_reg, op1_addr
3976-
| shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
3975+
if (Z_MODE(op1_addr) == IS_REG && Z_LVAL_P(Z_ZV(op2_addr)) == 2) {
3976+
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))+Ra(Z_REG(op1_addr))]
3977+
} else {
3978+
| GET_ZVAL_LVAL result_reg, op1_addr
3979+
| shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
3980+
}
39773981
} else {
3978-
| GET_ZVAL_LVAL result_reg, op2_addr
3979-
| shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op1_addr)))
3982+
if (Z_MODE(op2_addr) == IS_REG && Z_LVAL_P(Z_ZV(op1_addr)) == 2) {
3983+
| lea Ra(result_reg), [Ra(Z_REG(op2_addr))+Ra(Z_REG(op2_addr))]
3984+
} else {
3985+
| GET_ZVAL_LVAL result_reg, op2_addr
3986+
| shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op1_addr)))
3987+
}
39803988
}
39813989
} else if (opcode == ZEND_DIV &&
39823990
(Z_MODE(op2_addr) == IS_CONST_ZVAL &&
@@ -4593,6 +4601,8 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
45934601
| SAVE_VALID_OPLINE opline, r0
45944602
| jmp ->negative_shift
45954603
}
4604+
} else if (Z_MODE(op1_addr) == IS_REG && op2_lval == 1) {
4605+
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))+Ra(Z_REG(op1_addr))]
45964606
} else {
45974607
| GET_ZVAL_LVAL result_reg, op1_addr
45984608
| shl Ra(result_reg), op2_lval

0 commit comments

Comments
 (0)