From 972041d68dcffcbc6c896f3420d4e9473c8d0158 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 27 Aug 2020 22:59:30 +0300 Subject: [PATCH] Replace "mov %eax, %ecx; shl $1, $ecx" by "lea (%eax,%eax), %ecx" --- ext/opcache/jit/zend_jit_x86.dasc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index a0352ebac1..448a545e4d 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -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 && @@ -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 -- 2.40.0