]> granicus.if.org Git - php/commitdiff
Replace "mov %eax, %ecx; shl $1, $ecx" by "lea (%eax,%eax), %ecx"
authorDmitry Stogov <dmitry@zend.com>
Thu, 27 Aug 2020 19:59:30 +0000 (22:59 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 27 Aug 2020 19:59:30 +0000 (22:59 +0300)
ext/opcache/jit/zend_jit_x86.dasc

index a0352ebac1872b8e4d7d9b52101cdbacc75c9416..448a545e4d1946cd8ee6a69374b6a5ada776b6f3 100644 (file)
@@ -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