[php-src] jit-arm64: Fixed possible incorrect assumption if constant is a power of 2.
| From: | Dmitry Stogov | Date: | Wed, 21 Apr 2021 10:55:10 +0000 |
| Subject: | [php-src] jit-arm64: Fixed possible incorrect assumption if constant is a power of 2. | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-115725@lists.php.net to get a copy of this message | ||
Author: Dmitry Stogov (dstogov)
Date: 2021-04-21T13:52:03+03:00
Commit: https://github.com/php/php-src/commit/85961c5d05afe649c8524f68fa63fe5ec6379e4a
Raw diff: https://github.com/php/php-src/commit/85961c5d05afe649c8524f68fa63fe5ec6379e4a.diff
Fixed possible incorrect assumption if constant is a power of 2.
Changed paths:
M ext/opcache/jit/zend_jit_arm64.dasc
Diff:
diff --git a/ext/opcache/jit/zend_jit_arm64.dasc b/ext/opcache/jit/zend_jit_arm64.dasc
index 3ca2662489b8..c3577fa7b452 100644
--- a/ext/opcache/jit/zend_jit_arm64.dasc
+++ b/ext/opcache/jit/zend_jit_arm64.dasc
@@ -3063,40 +3063,40 @@ static int zend_jit_math_long_long(dasm_State **Dst,
}
if (opcode == ZEND_MUL &&
- ((Z_MODE(op2_addr) == IS_CONST_ZVAL &&
+ Z_MODE(op2_addr) == IS_CONST_ZVAL &&
IS_SIGNED_32BIT(Z_LVAL_P(Z_ZV(op2_addr))) &&
- is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr)))) ||
- (Z_MODE(op1_addr) == IS_CONST_ZVAL &&
- 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) {
- if (Z_LVAL_P(Z_ZV(op2_addr)) == 2) {
- if (Z_MODE(op1_addr) == IS_REG) {
- | adds Rx(result_reg), Rx(Z_REG(op1_addr)), Rx(Z_REG(op1_addr))
- } else {
- | GET_ZVAL_LVAL result_reg, op1_addr, TMP1
- | adds Rx(result_reg), Rx(result_reg), Rx(result_reg)
- }
+ is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr)))) {
+
+ if (Z_LVAL_P(Z_ZV(op2_addr)) == 2) {
+ if (Z_MODE(op1_addr) == IS_REG) {
+ | adds Rx(result_reg), Rx(Z_REG(op1_addr)), Rx(Z_REG(op1_addr))
} else {
| GET_ZVAL_LVAL result_reg, op1_addr, TMP1
- | mov TMP1, #floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
- | lsl Rx(result_reg), Rx(result_reg), TMP1
- | // TODO: overflow may be missed
+ | adds Rx(result_reg), Rx(result_reg), Rx(result_reg)
}
} else {
- if (Z_LVAL_P(Z_ZV(op1_addr)) == 2) {
- if (Z_MODE(op2_addr) == IS_REG) {
- | adds Rx(result_reg), Rx(Z_REG(op2_addr)), Rx(Z_REG(op2_addr))
- } else {
- | GET_ZVAL_LVAL result_reg, op2_addr, TMP1
- | adds Rx(result_reg), Rx(result_reg), Rx(result_reg)
- }
+ | GET_ZVAL_LVAL result_reg, op1_addr, TMP1
+ | mov TMP1, #floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
+ | lsl Rx(result_reg), Rx(result_reg), TMP1
+ | // TODO: overflow may be missed
+ }
+ } else if (opcode == ZEND_MUL &&
+ Z_MODE(op2_addr) == IS_CONST_ZVAL &&
+ IS_SIGNED_32BIT(Z_LVAL_P(Z_ZV(op2_addr))) &&
+ is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr)))) {
+
+ if (Z_LVAL_P(Z_ZV(op1_addr)) == 2) {
+ if (Z_MODE(op2_addr) == IS_REG) {
+ | adds Rx(result_reg), Rx(Z_REG(op2_addr)), Rx(Z_REG(op2_addr))
} else {
| GET_ZVAL_LVAL result_reg, op2_addr, TMP1
- | mov TMP1, #floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
- | lsl Rx(result_reg), Rx(result_reg), TMP1
- | // TODO: overflow may be missed
+ | adds Rx(result_reg), Rx(result_reg), Rx(result_reg)
}
+ } else {
+ | GET_ZVAL_LVAL result_reg, op2_addr, TMP1
+ | mov TMP1, #floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
+ | lsl Rx(result_reg), Rx(result_reg), TMP1
+ | // TODO: overflow may be missed
}
} else if (opcode == ZEND_DIV &&
(Z_MODE(op2_addr) == IS_CONST_ZVAL &&