From 6fd34f0809346fb30ee7a87e1edd3ffc70b1413a Mon Sep 17 00:00:00 2001 From: Keming Date: Tue, 3 Dec 2024 21:07:28 +0800 Subject: [PATCH] fix: simd binary ip for 32bit (#6) Signed-off-by: Keming --- src/simd.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/simd.rs b/src/simd.rs index aca6f93..3138df6 100644 --- a/src/simd.rs +++ b/src/simd.rs @@ -377,7 +377,8 @@ pub unsafe fn binary_dot_product(lhs: &[u64], rhs: &[u64]) -> u32 { _mm256_castsi256_si128(sum256), _mm256_extracti128_si256(sum256, 1), ); - sum += _mm_cvtsi128_si64(_mm_add_epi64(xa, _mm_shuffle_epi32(xa, 78))) as u32; + // this assumes the length is less than 2 ** 31 + sum += _mm_cvtsi128_si32(_mm_add_epi64(xa, _mm_shuffle_epi32(xa, 78))) as u32; sum }