[php-src] master: Fixed possible incorrect assumption if constant is a power of 2.
| From: | Dmitry Stogov | Date: | Wed, 21 Apr 2021 23:33:10 +0000 |
| Subject: | [php-src] master: Fixed possible incorrect assumption if constant is a power of 2. | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-115734@lists.php.net to get a copy of this message | ||
Author: Dmitry Stogov (dstogov)
Date: 2021-04-22T02:32:49+03:00
Commit: https://github.com/php/php-src/commit/3c37a3426b3e0bd11f009b930ebbdb9570cba233
Raw diff: https://github.com/php/php-src/commit/3c37a3426b3e0bd11f009b930ebbdb9570cba233.diff
Fixed possible incorrect assumption if constant is a power of 2.
Changed paths:
M ext/opcache/jit/zend_jit_x86.dasc
Diff:
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 41ac95b28e28..912e70cd6403 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -4244,26 +4244,26 @@ 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_power_of_two(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 if (opcode == ZEND_MUL &&
+ 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_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)))
- }
+ is_power_of_two(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 {
- 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)))
- }
+ | 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 &&