From 81f44d352f803358e939182b19b02a2df583857f Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Sat, 29 Jun 2024 15:01:18 -0700 Subject: [PATCH] SIMD scan16 for x86 + 32-bit versions --- ConflictSet.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index f0aa31f..3a75b45 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1823,9 +1823,21 @@ bool scan16(const InternalVersionT *vs, const uint8_t *is, int begin, int end, indices, _mm_max_epu8(indices, _mm_set1_epi8(end - begin)))); uint32_t compared = 0; +#if INTERNAL_VERSION_32_BIT + __m128i w4[4]; + memcpy(w4, vs, sizeof(w4)); + uint32_t rv; + memcpy(&rv, &readVersion, sizeof(rv)); + const auto rvVec = _mm_set1_epi32(rv); + const auto zero = _mm_setzero_si128(); + for (int i = 0; i < 4; ++i) { + compared |= _mm_movemask_ps(_mm_cmpgt_epi32(_mm_sub_epi32(w4[i], rvVec), zero)) << (i * 4); + } +#else for (int i = 0; i < 16; ++i) { compared |= (vs[i] > readVersion) << i; } +#endif return !(compared & mask); #else