From: Harmen Stoppels Date: Tue, 29 Jul 2025 12:25:16 +0000 (+0200) Subject: X86_AVX512VNNI: test _mm256_dpbusd_epi32 too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6affd01c0edc30bb7b5ff894670d779d417e77a;p=thirdparty%2Fzlib-ng.git X86_AVX512VNNI: test _mm256_dpbusd_epi32 too On RHEL9 the GCC is new enough to support AVX512-VNNI, but its assembler (binutils) is not and errors with ``` Error: unsupported instruction vpdpbusd ``` This was already addressed earlier in https://github.com/zlib-ng/zlib-ng/pull/1562 to some extent, except that a check for `_mm256_dpbusd_epi32` was not added, which is what the assembler errors over. --- diff --git a/cmake/detect-intrinsics.cmake b/cmake/detect-intrinsics.cmake index 484966e9..7f815409 100644 --- a/cmake/detect-intrinsics.cmake +++ b/cmake/detect-intrinsics.cmake @@ -164,13 +164,18 @@ macro(check_avx512vnni_intrinsics) endif() # Check whether compiler supports AVX512vnni intrinsics set(CMAKE_REQUIRED_FLAGS "${AVX512VNNIFLAG} ${NATIVEFLAG} ${ZNOLTOFLAG}") - check_c_source_compiles( - "#include - __m512i f(__m512i x, __m512i y) { - __m512i z = _mm512_setzero_epi32(); - return _mm512_dpbusd_epi32(z, x, y); - } - int main(void) { return 0; }" + check_c_source_compiles([=[ +#include +int main(void) { + const __m512i z512 = _mm512_setzero_si512(); + const __m256i z256 = _mm256_setzero_si256(); + volatile __m512i r512 = _mm512_dpbusd_epi32(z512, z512, z512); + volatile __m256i r256 = _mm256_dpbusd_epi32(z256, z256, z256); + (void)r512; + (void)r256; + return 0; +} +]=] HAVE_AVX512VNNI_INTRIN ) set(CMAKE_REQUIRED_FLAGS) diff --git a/configure b/configure index df946157..76176de7 100755 --- a/configure +++ b/configure @@ -1188,11 +1188,15 @@ check_avx512vnni_intrinsics() { # Check whether compiler supports AVX512-VNNI intrinsics cat > $test.c << EOF #include -__m512i f(__m512i x, __m512i y) { - __m512i z = _mm512_setzero_epi32(); - return _mm512_dpbusd_epi32(z, x, y); +int main(void) { + const __m512i z512 = _mm512_setzero_si512(); + const __m256i z256 = _mm256_setzero_si256(); + volatile __m512i r512 = _mm512_dpbusd_epi32(z512, z512, z512); + volatile __m256i r256 = _mm256_dpbusd_epi32(z256, z256, z256); + (void)r512; + (void)r256; + return 0; } -int main(void) { return 0; } EOF if try ${CC} ${CFLAGS} ${avx512vnniflag} $test.c; then echo "Checking for AVX512VNNI intrinsics ... Yes." | tee -a configure.log