@@ -4949,6 +4949,9 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
4949
4949
4950
4950
if (opcode == ZEND_MOD) {
4951
4951
result_reg = ZREG_RAX;
4952
+ if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RAX) {
4953
+ | mov aword T1, r0 // save
4954
+ }
4952
4955
} else if (Z_MODE(res_addr) == IS_REG) {
4953
4956
if ((opline->opcode == ZEND_SL || opline->opcode == ZEND_SR)
4954
4957
&& opline->op2_type != IS_CONST) {
@@ -5053,18 +5056,23 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
5053
5056
if (op2_lval == 0) {
5054
5057
| SET_EX_OPLINE opline, r0
5055
5058
| jmp ->mod_by_zero
5056
- } else if (op2_lval == -1) {
5057
- | xor Ra(result_reg), Ra(result_reg)
5058
5059
} else {
5059
5060
result_reg = ZREG_RDX;
5060
- | GET_ZVAL_LVAL ZREG_RAX, op1_addr
5061
- | GET_ZVAL_LVAL ZREG_RCX, op2_addr
5062
- |.if X64
5063
- | cqo
5064
- |.else
5065
- | cdq
5066
- |.endif
5067
- | idiv Ra(ZREG_RCX)
5061
+ if (op2_lval == -1) {
5062
+ | xor Ra(result_reg), Ra(result_reg)
5063
+ } else {
5064
+ | GET_ZVAL_LVAL ZREG_RAX, op1_addr
5065
+ | GET_ZVAL_LVAL ZREG_RCX, op2_addr
5066
+ |.if X64
5067
+ | cqo
5068
+ |.else
5069
+ | cdq
5070
+ |.endif
5071
+ | idiv Ra(ZREG_RCX)
5072
+ }
5073
+ if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RAX) {
5074
+ | mov r0, aword T1 // restore
5075
+ }
5068
5076
}
5069
5077
} else {
5070
5078
if (!op2_range || (op2_range->min <= 0 && op2_range->max >= 0)) {
@@ -5115,6 +5123,9 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
5115
5123
} else if (Z_MODE(op2_addr) == IS_REG) {
5116
5124
| idiv Ra(Z_REG(op2_addr))
5117
5125
}
5126
+ if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RAX) {
5127
+ | mov r0, aword T1 // restore
5128
+ }
5118
5129
}
5119
5130
} else if (same_ops) {
5120
5131
| GET_ZVAL_LVAL result_reg, op1_addr
0 commit comments