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))
105 for (;
len && ((uintptr_t)
buf & 7); --
len)
106 crc0 = _mm_crc32_u8(crc0, *
buf++);
107 while (((uintptr_t)
buf & 56) &&
len >= 8)
109 crc0 = _mm_crc32_u64(crc0, *(
const uint64_t *)
buf);
117 const char *end =
buf +
len;
118 const char *limit =
buf +
len - 64;
122 __m512i x0 = _mm512_loadu_si512((
const void *)
buf),
126 k = _mm512_broadcast_i32x4(_mm_setr_epi32(0x740eef02, 0, 0x9e4addf8, 0));
127 x0 = _mm512_xor_si512(_mm512_castsi128_si512(_mm_cvtsi32_si128(crc0)), x0);
133 y0 = clmul_lo(x0, k), x0 = clmul_hi(x0, k);
134 x0 = _mm512_ternarylogic_epi64(x0, y0,
135 _mm512_loadu_si512((
const void *)
buf),
141 k = _mm512_setr_epi32(0x1c291d04, 0, 0xddc0152b, 0,
142 0x3da6d0cb, 0, 0xba4fc28e, 0,
143 0xf20c0dfe, 0, 0x493c7d27, 0,
145 y0 = clmul_lo(x0, k), k = clmul_hi(x0, k);
146 y0 = _mm512_xor_si512(y0, k);
147 z0 = _mm_ternarylogic_epi64(_mm512_castsi512_si128(y0),
148 _mm512_extracti32x4_epi32(y0, 1),
149 _mm512_extracti32x4_epi32(y0, 2),
151 z0 = _mm_xor_si128(z0, _mm512_extracti32x4_epi32(x0, 3));
154 crc0 = _mm_crc32_u64(0, _mm_extract_epi64(z0, 0));
155 crc0 = _mm_crc32_u64(crc0, _mm_extract_epi64(z0, 1));
159 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