Skip to content

Commit 284df4a

Browse files
authored
Merge pull request #49 from jeremydixon22/fix/gcc13-avx2-static-initializer
fix: replace static __m256i initializer with byte array to fix GCC 13 build
2 parents b68d34a + 2180ee9 commit 284df4a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/distance-avx2.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,11 @@ float int8_distance_cosine_avx2 (const void *a, const void *b, int n) {
959959

960960
// MARK: - BIT -
961961

962-
// lookup table for popcount of 4-bit values
963-
static const __m256i popcount_lut = _mm256_setr_epi8(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
962+
// lookup table for popcount of 4-bit values (plain byte array — avoids GCC static-init restriction on intrinsics)
963+
static const char popcount_lut_bytes[32] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
964964

965965
static inline __m256i popcount_avx2(__m256i v) {
966+
__m256i popcount_lut = _mm256_loadu_si256((const __m256i*)popcount_lut_bytes);
966967
__m256i low_mask = _mm256_set1_epi8(0x0f);
967968
__m256i lo = _mm256_and_si256(v, low_mask);
968969
__m256i hi = _mm256_and_si256(_mm256_srli_epi16(v, 4), low_mask);

0 commit comments

Comments
 (0)