From a4ad686ef3efdbdee988a278fff33e47cb1a857a Mon Sep 17 00:00:00 2001 From: Martin Dimitrov Date: Tue, 19 May 2026 20:42:37 -0700 Subject: [PATCH] bitops: switch AVX2 scan to epi64 comparison for consistency Use _mm256_cmpeq_epi64 + _mm256_movemask_pd in redisBitposScanAVX2, matching the qword-granularity comparison style of the AVX512 path which uses _mm512_cmpeq_epi64_mask. --- src/bitops.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bitops.c b/src/bitops.c index 816af5c80..8fb201168 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -414,12 +414,13 @@ static unsigned long redisBitposScanAVX2(unsigned char *p, unsigned long count, int bit) { unsigned long scanned = 0; __m256i skip = bit ? _mm256_setzero_si256() - : _mm256_set1_epi8((char)0xFF); + : _mm256_set1_epi64x(-1LL); while (count >= 32) { __m256i data = _mm256_loadu_si256((__m256i *)p); - int eq = _mm256_movemask_epi8(_mm256_cmpeq_epi8(data, skip)); - if (eq != -1) break; + int eq = _mm256_movemask_pd(_mm256_castsi256_pd( + _mm256_cmpeq_epi64(data, skip))); + if (eq != 0xF) break; p += 32; count -= 32; scanned += 32;