mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-07 09:17:29 +00:00
Fixed zend_long_is_power_of_two/zend_long_floor_log2 mess
This commit is contained in:
1 parent
e1e5aedf98
commit
7210c31700
3 files changed
+12
-12
No files matched your search
@@ -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 &&
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#ifndef ZEND_JIT_INTERNAL_H
|
||||
#define ZEND_JIT_INTERNAL_H
|
||||
|
||||
#include "zend_bitset.h"
|
||||
|
||||
/* Register Set */
|
||||
#define ZEND_REGSET_EMPTY 0
|
||||
|
||||
@@ -743,10 +745,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/ */
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
Reference in new issue
Block a user