Skip to content

Commit 1e59a8d

Browse files
committed
Improve code for MUL overflow detection (less instructions and less
temporary registers)
1 parent 4765331 commit 1e59a8d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,9 +3903,9 @@ static int zend_jit_math_long_long(dasm_State **Dst,
39033903
| NIY // TODO: test
39043904
#endif
39053905
} else if (opcode == ZEND_MUL) {
3906-
| GET_ZVAL_LVAL ZREG_TMP2, op1_addr, TMP1
3907-
| GET_ZVAL_LVAL ZREG_TMP3, op2_addr, TMP1
3908-
| mul Rx(result_reg), TMP2, TMP3
3906+
| GET_ZVAL_LVAL ZREG_TMP1, op1_addr, TMP1
3907+
| GET_ZVAL_LVAL ZREG_TMP2, op2_addr, TMP2
3908+
| mul Rx(result_reg), TMP1, TMP2
39093909
if(may_overflow) {
39103910
/* Use 'smulh' to get the upper 64 bits fo the 128-bit result.
39113911
* For signed multiplication, the top 65 bits of the result will contain
@@ -3915,9 +3915,8 @@ static int zend_jit_math_long_long(dasm_State **Dst,
39153915
* Flag: bne -> overflow. beq -> no overflow.
39163916
*/
39173917
use_ovf_flag = 0;
3918-
| smulh TMP1, TMP2, TMP3
3919-
| asr TMP2, Rx(result_reg), #63
3920-
| cmp TMP1, TMP2
3918+
| smulh TMP1, TMP1, TMP2
3919+
| cmp TMP1, Rx(result_reg), asr #63
39213920
}
39223921
} else {
39233922
| GET_ZVAL_LVAL result_reg, op1_addr, TMP1

0 commit comments

Comments
 (0)