18#ifdef USE_AVX512_CRC32C_WITH_RUNTIME_CHECK
29 const unsigned char *p =
data;
49 crc = _mm_crc32_u32(
crc, *((
const unsigned int *) p));
60 crc = _mm_crc32_u32(
crc, *((
const unsigned int *) p));
68 crc = _mm_crc32_u8(
crc, *p);
75#ifdef USE_AVX512_CRC32C_WITH_RUNTIME_CHECK
90#define clmul_lo(a, b) (_mm512_clmulepi64_epi128((a), (b), 0))
91#define clmul_hi(a, b) (_mm512_clmulepi64_epi128((a), (b), 17))
104 for (;
len && ((uintptr_t)
buf & 7); --
len)
105 crc0 = _mm_crc32_u8(crc0, *
buf++);
106 while (((uintptr_t)
buf & 56) &&
len >= 8)
108 crc0 = _mm_crc32_u64(crc0, *(
const uint64_t *)
buf);
116 const char *end =
buf +
len;
117 const char *limit =
buf +
len - 64;
121 __m512i x0 = _mm512_loadu_si512((
const void *)
buf),
125 k = _mm512_broadcast_i32x4(_mm_setr_epi32(0x740eef02, 0, 0x9e4addf8, 0));
126 x0 = _mm512_xor_si512(_mm512_castsi128_si512(_mm_cvtsi32_si128(crc0)), x0);
132 y0 = clmul_lo(x0, k), x0 = clmul_hi(x0, k);
133 x0 = _mm512_ternarylogic_epi64(x0, y0,
134 _mm512_loadu_si512((
const void *)
buf),
140 k = _mm512_setr_epi32(0x1c291d04, 0, 0xddc0152b, 0,
141 0x3da6d0cb, 0, 0xba4fc28e, 0,
142 0xf20c0dfe, 0, 0x493c7d27, 0,
144 y0 = clmul_lo(x0, k), k = clmul_hi(x0, k);
145 y0 = _mm512_xor_si512(y0, k);
146 z0 = _mm_ternarylogic_epi64(_mm512_castsi512_si128(y0),
147 _mm512_extracti32x4_epi32(y0, 1),
148 _mm512_extracti32x4_epi32(y0, 2),
150 z0 = _mm_xor_si128(z0, _mm512_extracti32x4_epi32(x0, 3));
153 crc0 = _mm_crc32_u64(0, _mm_extract_epi64(z0, 0));
154 crc0 = _mm_crc32_u64(crc0, _mm_extract_epi64(z0, 1));
158 return pg_comp_crc32c_sse42(crc0,
buf,
len);
#define pg_attribute_target(...)
pg_attribute_no_sanitize_alignment() pg_attribute_target("sse4.2") pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc
const unsigned char * pend