]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
X86_AVX512VNNI: test _mm256_dpbusd_epi32 too
authorHarmen Stoppels <me@harmenstoppels.nl>
Tue, 29 Jul 2025 12:25:16 +0000 (14:25 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 3 Aug 2025 18:45:33 +0000 (20:45 +0200)
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.

cmake/detect-intrinsics.cmake
configure

index 484966e9f77160e9c64bc67043112e3800f004e7..7f815409c36de18957e4bb3d219f22e8b346af1a 100644 (file)
@@ -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 <immintrin.h>
-        __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 <immintrin.h>
+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)
index df946157a043d0d1427f9e9cd329e14853c3260a..76176de729188ec277d769f63fa24a5a2769f761 100755 (executable)
--- a/configure
+++ b/configure
@@ -1188,11 +1188,15 @@ check_avx512vnni_intrinsics() {
     # Check whether compiler supports AVX512-VNNI intrinsics
     cat > $test.c << EOF
 #include <immintrin.h>
-__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