]> granicus.if.org Git - php/commitdiff
[AArch64] Use NEON to initialize zend_hash
authorSebastian Pop <spop@amazon.com>
Wed, 17 Apr 2019 15:03:37 +0000 (15:03 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 7 May 2019 14:21:44 +0000 (16:21 +0200)
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>

Zend/zend_hash.c

index e4024d9688a036d6b78b48fbed8661eaf69439b5..56695c42293a2f62d0f8c6eb8edd3f7fb8a87c03 100644 (file)
 #include "zend_globals.h"
 #include "zend_variables.h"
 
+#if defined(__aarch64__)
+# include <arm_neon.h>
+#endif
+
 #ifdef __SSE2__
 # include <mmintrin.h>
 # include <emmintrin.h>
@@ -156,6 +160,14 @@ static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht)
                        _mm_storeu_si128((__m128i*)&HT_HASH_EX(data,  8), xmm0);
                        _mm_storeu_si128((__m128i*)&HT_HASH_EX(data, 12), xmm0);
                } while (0);
+#elif defined(__aarch64__)
+               do {
+                       int32x4_t t = vdupq_n_s32(-1);
+                       vst1q_s32((int32_t*)&HT_HASH_EX(data,  0), t);
+                       vst1q_s32((int32_t*)&HT_HASH_EX(data,  4), t);
+                       vst1q_s32((int32_t*)&HT_HASH_EX(data,  8), t);
+                       vst1q_s32((int32_t*)&HT_HASH_EX(data, 12), t);
+               } while (0);
 #else
                HT_HASH_EX(data,  0) = -1;
                HT_HASH_EX(data,  1) = -1;