Skip to content

Commit 5487c05

Browse files
committed
Fix undefined behaviour in crc32_avx512()
The code was mistakenly using _mm512_castsi128_si512() to convert __m128i to __m512i, which leaves the upper bits undefined. Use instead _mm512_zextsi128_si512() which zero-extends as needed. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent a1bba0e commit 5487c05

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mysys/crc32/crc32c_x86.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ USE_VPCLMULQDQ
213213
static unsigned crc32_avx512(unsigned crc, const char *buf, size_t size,
214214
const crc32_tab &tab)
215215
{
216-
const __m512i crc_in = _mm512_castsi128_si512(_mm_cvtsi32_si128(~crc)),
216+
const __m512i crc_in = _mm512_zextsi128_si512(_mm_cvtsi32_si128(~crc)),
217217
b512 = _mm512_broadcast_i32x4(_mm_load_epi32(tab.b512));
218218
__m128i crc_out;
219219
__m512i lo;

0 commit comments

Comments
 (0)