Skip to content

Commit 77d0587

Browse files
committed
Use "lea" to add/sub register with constant
1 parent a459799 commit 77d0587

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3826,6 +3826,21 @@ static int zend_jit_math_long_long(dasm_State **Dst,
38263826
is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr))))) {
38273827
| GET_ZVAL_LVAL result_reg, op1_addr
38283828
| shr Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
3829+
} else if (opcode == ZEND_ADD &&
3830+
!may_overflow &&
3831+
Z_MODE(op1_addr) == IS_REG &&
3832+
Z_MODE(op2_addr) == IS_CONST_ZVAL) {
3833+
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))+Z_LVAL_P(Z_ZV(op2_addr))]
3834+
} else if (opcode == ZEND_ADD &&
3835+
!may_overflow &&
3836+
Z_MODE(op2_addr) == IS_REG &&
3837+
Z_MODE(op1_addr) == IS_CONST_ZVAL) {
3838+
| lea Ra(result_reg), [Ra(Z_REG(op2_addr))+Z_LVAL_P(Z_ZV(op1_addr))]
3839+
} else if (opcode == ZEND_SUB &&
3840+
!may_overflow &&
3841+
Z_MODE(op1_addr) == IS_REG &&
3842+
Z_MODE(op2_addr) == IS_CONST_ZVAL) {
3843+
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))-Z_LVAL_P(Z_ZV(op2_addr))]
38293844
} else {
38303845
| GET_ZVAL_LVAL result_reg, op1_addr
38313846
if (same_ops && opcode != ZEND_DIV) {

0 commit comments

Comments
 (0)