From 461e07822a3cdfac8a27c3d891fb05404805166e Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Sat, 29 Jun 2024 15:10:05 -0700 Subject: [PATCH] 32-bit x86 simd for the other scan16 too --- ConflictSet.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index df9be5e..9c2d62b 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1895,6 +1895,20 @@ inline __attribute((always_inline)) bool scan16(const InternalVersionT *vs, conflict &= end == 16 ? -1 : (uint64_t(1) << (end << 2)) - 1; conflict >>= begin << 2; return !conflict; +#elif INTERNAL_VERSION_32_BIT && defined(HAS_AVX) + __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(); + uint32_t conflict = 0; + for (int i = 0; i < 4; ++i) { + conflict |= _mm_movemask_ps(_mm_cmpgt_epi32(_mm_sub_epi32(w4[i], rvVec), zero)) << (i * 4); + } + conflict &= (1 << end) - 1; + conflict >>= begin; + return !conflict; #else uint64_t conflict = 0; for (int i = 0; i < 16; ++i) {