Skip to content

Commit 96d8268

Browse files
author
Sebastian Pop
committed
use NEON to initialize zend_hash
On A72, google-benchmark measure before and after the patch: -------------------------------------------------------------- Benchmark Time CPU Iterations -------------------------------------------------------------- BM_hash_init_before 43.6 ns 43.6 ns 16052937 BM_hash_init_after 27.0 ns 27.0 ns 25877296 Patch written by Ali Saidi <alisaidi@amazon.com> and Sebastian Pop <spop@amazon.com>
1 parent fc42ac2 commit 96d8268

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Zend/zend_hash.c

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "zend_globals.h"
2323
#include "zend_variables.h"
2424

25+
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
26+
# include <arm_neon.h>
27+
#endif
28+
2529
#ifdef __SSE2__
2630
# include <mmintrin.h>
2731
# include <emmintrin.h>
@@ -156,6 +160,14 @@ static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht)
156160
_mm_storeu_si128((__m128i*)&HT_HASH_EX(data, 8), xmm0);
157161
_mm_storeu_si128((__m128i*)&HT_HASH_EX(data, 12), xmm0);
158162
} while (0);
163+
#elif defined(__aarch64__)
164+
do {
165+
int32x4_t t = vdupq_n_s32(-1);
166+
vst1q_s32((int32_t*)&HT_HASH_EX(data, 0), t);
167+
vst1q_s32((int32_t*)&HT_HASH_EX(data, 4), t);
168+
vst1q_s32((int32_t*)&HT_HASH_EX(data, 8), t);
169+
vst1q_s32((int32_t*)&HT_HASH_EX(data, 12), t);
170+
} while (0);
159171
#else
160172
HT_HASH_EX(data, 0) = -1;
161173
HT_HASH_EX(data, 1) = -1;

0 commit comments

Comments
 (0)