diff options
author | Snappy Team <no-reply@google.com> | 2021-07-07 19:22:28 +0000 |
---|---|---|
committer | Victor Costan <costan@google.com> | 2021-08-02 14:49:57 +0000 |
commit | 9cc3689b2120bd25a74f264f05ed8692c9e22dfe (patch) | |
tree | 07458abb3846abcb0f4f42f709900163b51361c6 /snappy-internal.h | |
parent | b4888f76161debdbcde30a64be577b82fd40de29 (diff) | |
download | snappy-git-9cc3689b2120bd25a74f264f05ed8692c9e22dfe.tar.gz |
Optimize memset to pure SIMD because compilers generate consistently bad code. clang for ARM and gcc for x86 https://gcc.godbolt.org/z/oxeGG7aEx
PiperOrigin-RevId: 383467656
Diffstat (limited to 'snappy-internal.h')
-rw-r--r-- | snappy-internal.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/snappy-internal.h b/snappy-internal.h index ad2b36a..f1aafa9 100644 --- a/snappy-internal.h +++ b/snappy-internal.h @@ -56,6 +56,9 @@ inline void V128_StoreU(V128* dst, V128 val); // Each packed integer in the shuffle mask must be in [0,16). inline V128 V128_Shuffle(V128 input, V128 shuffle_mask); +// Constructs V128 with 16 chars |c|. +inline V128 V128_DupChar(char c); + #if SNAPPY_HAVE_SSSE3 inline V128 V128_Load(const V128* src) { return _mm_load_si128(src); } @@ -66,6 +69,9 @@ inline void V128_StoreU(V128* dst, V128 val) { _mm_storeu_si128(dst, val); } inline V128 V128_Shuffle(V128 input, V128 shuffle_mask) { return _mm_shuffle_epi8(input, shuffle_mask); } + +inline V128 V128_DupChar(char c) { return _mm_set1_epi8(c); } + #else inline V128 V128_Load(const V128* src) { return vld1q_u8(reinterpret_cast<const uint8_t*>(src)); @@ -83,6 +89,8 @@ inline V128 V128_Shuffle(V128 input, V128 shuffle_mask) { assert(vminvq_u8(shuffle_mask) >= 0 && vmaxvq_u8(shuffle_mask) <= 15); return vqtbl1q_u8(input, shuffle_mask); } + +inline V128 V128_DupChar(char c) { return vdupq_n_u8(c); } #endif #endif // SNAPPY_HAVE_VECTOR_BYTE_SHUFFLE |