Browse Source

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>
pull/4271/head
Kristian Nielsen 1 month ago
parent
commit
5487c059c6
  1. 2
      mysys/crc32/crc32c_x86.cc

2
mysys/crc32/crc32c_x86.cc

@ -213,7 +213,7 @@ USE_VPCLMULQDQ
static unsigned crc32_avx512(unsigned crc, const char *buf, size_t size,
const crc32_tab &tab)
{
const __m512i crc_in = _mm512_castsi128_si512(_mm_cvtsi32_si128(~crc)),
const __m512i crc_in = _mm512_zextsi128_si512(_mm_cvtsi32_si128(~crc)),
b512 = _mm512_broadcast_i32x4(_mm_load_epi32(tab.b512));
__m128i crc_out;
__m512i lo;

Loading…
Cancel
Save