Assume the assembler supports all x86 SSE/AVX instructions

This commit is contained in:
Andrea Mazzoleni 2026-05-28 01:12:17 +02:00
parent ff2e137201
commit d5fe6f14f6
13 changed files with 225 additions and 782 deletions

View file

@ -214,126 +214,9 @@ AC_CHECK_CC_OPT([-Wno-zero-length-bounds], CFLAGS="$CFLAGS -Wno-zero-length-boun
dnl Checks for asm
AC_ARG_ENABLE([asm],
AS_HELP_STRING([--disable-asm], [Disable inline assembly]))
AS_IF([test "x$enable_asm" != "xno"],
[AC_DEFINE([HAVE_ASSEMBLY], [1], [Define to 1 if inline assembly should be used.])]
dnl AS_IF(HAVE_ASSEMBLY) NOT closed here
dnl Checks for AS supporting the SSE2 instructions.
AC_MSG_CHECKING([for sse2])
asmsse2=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined(__i386__) || defined(__x86_64__)
void f(void)
{
asm volatile("pxor %xmm0,%xmm1");
}
#else
#error not x86
#endif
]])],
[AC_DEFINE([HAVE_SSE2], [1], [Define to 1 if sse2 is supported by the assembler.]) asmsse2=yes])
AC_MSG_RESULT([$asmsse2])
dnl Checks for AS supporting the SSSE3 instructions.
AC_MSG_CHECKING([for ssse3])
asmssse3=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined(__i386__) || defined(__x86_64__)
void f(void)
{
asm volatile("pshufb %xmm0,%xmm1");
}
#else
#error not x86
#endif
]])],
[AC_DEFINE([HAVE_SSSE3], [1], [Define to 1 if ssse3 is supported by the assembler.]) asmssse3=yes])
AC_MSG_RESULT([$asmssse3])
dnl Checks for AS supporting the SSE4.2 instructions.
AC_MSG_CHECKING([for sse42])
asmsse42=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined(__i386__) || defined(__x86_64__)
unsigned f(unsigned crc, unsigned char b)
{
asm volatile("crc32b %1, %0" : "+r" (crc) : "rm" (b));
return crc;
}
#else
#error not x86
#endif
]])],
[AC_DEFINE([HAVE_SSE42], [1], [Define to 1 if sse4.2 is supported by the assembler.]) asmsse42=yes])
AC_MSG_RESULT([$asmsse42])
dnl Checks for AS supporting the AVX2 instructions.
AC_MSG_CHECKING([for avx2])
asmavx2=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined(__i386__) || defined(__x86_64__)
void f(void* ptr)
{
asm volatile("vbroadcasti128 %0, %%ymm0" : : "m" (ptr));
}
#else
#error not x86
#endif
]])],
[AC_DEFINE([HAVE_AVX2], [1], [Define to 1 if avx2 is supported by the assembler.]) asmavx2=yes])
AC_MSG_RESULT([$asmavx2])
dnl Checks for AS supporting the AVX2FFNI instructions.
AC_MSG_CHECKING([for avx2gfni])
asmavx2gfni=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined(__x86_64__)
void f(void* ptr)
{
asm volatile ("vgf2p8mulb %0, %%ymm2, %%ymm2" : : "m" (ptr));
}
#else
#error not x86
#endif
]])],
[AC_DEFINE([HAVE_AVX2GFNI], [1], [Define to 1 if avx2gfni is supported by the assembler.]) asmavx2gfni=yes])
AC_MSG_RESULT([$asmavx2gfni])
dnl Checks for AS supporting the AVX512BW instructions.
AC_MSG_CHECKING([for avx512bw])
asmavx512bw=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined(__x86_64__)
void f(void* ptr)
{
asm volatile("vpshufb %0, %%zmm0, %%zmm1" : : "m" (ptr));
}
#else
#error not x86
#endif
]])],
[AC_DEFINE([HAVE_AVX512BW], [1], [Define to 1 if avx512bw is supported by the assembler.]) asmavx512bw=yes])
AC_MSG_RESULT([$asmavx512bw])
dnl Checks for AS supporting the AVX512GFNI instructions.
AC_MSG_CHECKING([for avx512gfni])
asmavx512gfni=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if defined(__x86_64__)
void f(void* ptr)
{
asm volatile ("vgf2p8mulb %0, %%zmm2, %%zmm2" : : "m" (ptr));
}
#else
#error not x86
#endif
]])],
[AC_DEFINE([HAVE_AVX512GFNI], [1], [Define to 1 if avx512gfni is supported by the assembler.]) asmavx512gfni=yes])
AC_MSG_RESULT([$asmavx512gfni])
dnl AS_IF(HAVE_ASSEMBLY) closed here
)
AS_IF([test "x$enable_asm" != "xno"], [
AC_DEFINE([HAVE_ASSEMBLY], [1], [Define to 1 if inline assembly should be used.])
])
dnl Checks for test environment
AS_CASE([$host],