Add AVX2 implementation for Adler32.

This commit is contained in:
2021-09-28 22:30:57 +01:00
parent 00a8cb8668
commit fe773bd1b6
6 changed files with 192 additions and 1 deletions

30
simd.c
View File

@@ -35,6 +35,29 @@ static void cpuid(int info, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigne
#endif
}
static void cpuidex(int info, int count, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx)
{
#ifdef _MSC_VER
unsigned int registers[4];
__cpuidex(registers, info, count);
*eax = registers[0];
*ebx = registers[1];
*ecx = registers[2];
*edx = registers[3];
#else
/* GCC, clang */
unsigned int _eax;
unsigned int _ebx;
unsigned int _ecx;
unsigned int _edx;
__cpuid_count(info, count, _eax, _ebx, _ecx, _edx);
*eax = _eax;
*ebx = _ebx;
*ecx = _ecx;
*edx = _edx;
#endif
}
int have_clmul(void)
{
unsigned eax, ebx, ecx, edx;
@@ -56,4 +79,11 @@ int have_ssse3(void)
return ecx & 0x200;
}
int have_avx2(void)
{
unsigned eax, ebx, ecx, edx;
cpuidex(7 /* extended feature bits */, 0, &eax, &ebx, &ecx, &edx);
return ebx & 0x20;
}
#endif