Created
May 18, 2021 09:32
-
-
Save dstogov/c1b00975068f59d6f57e33822596999a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ext/opcache/jit/zend_jit_arm64.dasc b/ext/opcache/jit/zend_jit_arm64.dasc | |
index fea32f9c0a..d1cd697ec5 100644 | |
--- a/ext/opcache/jit/zend_jit_arm64.dasc | |
+++ b/ext/opcache/jit/zend_jit_arm64.dasc | |
@@ -3902,9 +3902,9 @@ static int zend_jit_math_long_long(dasm_State **Dst, | |
| lsl Rx(result_reg), Rx(result_reg), TMP1 | |
} else if (opcode == ZEND_DIV && | |
(Z_MODE(op2_addr) == IS_CONST_ZVAL && | |
- is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr))))) { | |
+ zend_long_is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr))))) { | |
| GET_ZVAL_LVAL result_reg, op1_addr, TMP1 | |
- | asr Rx(result_reg), Rx(result_reg), #floor_log2(Z_LVAL_P(Z_ZV(op2_addr))) | |
+ | asr Rx(result_reg), Rx(result_reg), #zend_long_floor_log2(Z_LVAL_P(Z_ZV(op2_addr))) | |
#if 0 | |
/* x86 specific optimizations through LEA instraction are not supported on ARM */ | |
} else if (opcode == ZEND_ADD && | |
diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h | |
index f29c4b509e..63933003a5 100644 | |
--- a/ext/opcache/jit/zend_jit_internal.h | |
+++ b/ext/opcache/jit/zend_jit_internal.h | |
@@ -743,10 +743,10 @@ static zend_always_inline bool zend_long_is_power_of_two(zend_long x) | |
return (x > 0) && !(x & (x - 1)); | |
} | |
-static zend_always_inline uint32_t zend_long_floor_log2(uint64_t x) | |
+static zend_always_inline uint32_t zend_long_floor_log2(zend_long x) | |
{ | |
ZEND_ASSERT(zend_long_is_power_of_two(x)); | |
- return __builtin_ctzll(x); | |
+ return zend_ulong_ntz(x); | |
} | |
/* from http://aggregate.org/MAGIC/ */ | |
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc | |
index 31a19dcc1f..52efe13cd7 100644 | |
--- a/ext/opcache/jit/zend_jit_x86.dasc | |
+++ b/ext/opcache/jit/zend_jit_x86.dasc | |
@@ -4212,10 +4212,9 @@ static int zend_jit_math_long_long(dasm_State **Dst, | |
Z_MODE(op2_addr) == IS_CONST_ZVAL && | |
!may_overflow && | |
Z_LVAL_P(Z_ZV(op2_addr)) > 0 && | |
- IS_SIGNED_32BIT(Z_LVAL_P(Z_ZV(op2_addr))) && | |
- is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr)))) { | |
+ zend_long_is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr)))) { | |
| GET_ZVAL_LVAL result_reg, op1_addr | |
- | shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr))) | |
+ | shl Ra(result_reg), zend_long_floor_log2(Z_LVAL_P(Z_ZV(op2_addr))) | |
} else if (opcode == ZEND_MUL && | |
Z_MODE(op1_addr) == IS_CONST_ZVAL && | |
Z_LVAL_P(Z_ZV(op1_addr)) == 2) { | |
@@ -4229,15 +4228,14 @@ static int zend_jit_math_long_long(dasm_State **Dst, | |
Z_MODE(op1_addr) == IS_CONST_ZVAL && | |
!may_overflow && | |
Z_LVAL_P(Z_ZV(op1_addr)) > 0 && | |
- IS_SIGNED_32BIT(Z_LVAL_P(Z_ZV(op1_addr))) && | |
- is_power_of_two(Z_LVAL_P(Z_ZV(op1_addr)))) { | |
+ zend_long_is_power_of_two(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))) | |
+ | shl Ra(result_reg), zend_long_floor_log2(Z_LVAL_P(Z_ZV(op1_addr))) | |
} else if (opcode == ZEND_DIV && | |
(Z_MODE(op2_addr) == IS_CONST_ZVAL && | |
- is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr))))) { | |
+ zend_long_is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr))))) { | |
| GET_ZVAL_LVAL result_reg, op1_addr | |
- | shr Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr))) | |
+ | shr Ra(result_reg), zend_long_floor_log2(Z_LVAL_P(Z_ZV(op2_addr))) | |
} else if (opcode == ZEND_ADD && | |
!may_overflow && | |
Z_MODE(op1_addr) == IS_REG && |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment