diff --git a/speed.c b/speed.c index 9aa164e8..5d98eec3 100644 --- a/speed.c +++ b/speed.c @@ -177,7 +177,7 @@ void speed(void) } } SPEED_STOP - printf("CRC intel-crc32l %"PRIu64" [MB/s]\n", ds / dt); + printf("CRC intel-crc32 %"PRIu64" [MB/s]\n", ds / dt); } #endif SPEED_START { diff --git a/util.c b/util.c index 17d8954d..d553bb9c 100644 --- a/util.c +++ b/util.c @@ -1093,13 +1093,27 @@ uint32_t crc32c_gen(uint32_t crc, const unsigned char* ptr, unsigned size) uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size) { +#if defined(__x86_64__) + uint64_t crc64; +#endif + crc ^= CRC_IV; +#if defined(__x86_64__) + crc64 = crc; + while (size >= 8) { + asm volatile ("crc32q %1, %0\n" : "+r" (crc64) : "rm" (*(uint64_t*)ptr)); + ptr += 8; + size -= 8; + } + crc = crc64; +#else while (size >= 4) { asm volatile ("crc32l %1, %0\n" : "+r" (crc) : "rm" (*(uint32_t*)ptr)); ptr += 4; size -= 4; } +#endif while (size) { asm volatile ("crc32b %1, %0\n" : "+r" (crc) : "rm" (*ptr));