Skip to content

Commit

Permalink
lib/x86: adding missing MSVC and Apple clang version checks
Browse files Browse the repository at this point in the history
Most of the recently added code that uses newer x86 intrinsics (AVX-512,
VPCLMULQDQ, AVX-VNNI) is being compiled unconditionally when the
compiler is MSVC or Apple clang.  This is inconsistent with the minimum
versions of these compilers that we claim to support.  Therefore, add
the needed checks against _MSC_VER and __apple_build_version__.
  • Loading branch information
ebiggers committed Mar 2, 2024
1 parent fb3d7e7 commit 3fe22f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/x86/adler32_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ adler32_avx2_chunk(const __m256i *p, const __m256i *const end, u32 *s1, u32 *s2)
* implementation, but instead of using AVX-512 it uses AVX2 plus AVX-VNNI.
* AVX-VNNI adds dot product instructions to CPUs without AVX-512.
*/
#if GCC_PREREQ(11, 1) || CLANG_PREREQ(12, 0, 0) || defined(_MSC_VER)
#if GCC_PREREQ(11, 1) || CLANG_PREREQ(12, 0, 13000000) || MSVC_PREREQ(1930)
# define adler32_avx2_vnni adler32_avx2_vnni
# define FUNCNAME adler32_avx2_vnni
# define FUNCNAME_CHUNK adler32_avx2_vnni_chunk
Expand Down Expand Up @@ -340,7 +340,7 @@ adler32_avx2_vnni_chunk(const __m256i *p, const __m256i *const end,
* AVX512BW/AVX512VNNI implementation. Uses the vpdpbusd (dot product)
* instruction from AVX512VNNI.
*/
#if GCC_PREREQ(8, 1) || CLANG_PREREQ(6, 0, 0) || defined(_MSC_VER)
#if GCC_PREREQ(8, 1) || CLANG_PREREQ(6, 0, 10000000) || MSVC_PREREQ(1920)
# define adler32_avx512_vnni adler32_avx512_vnni
# define FUNCNAME adler32_avx512_vnni
# define FUNCNAME_CHUNK adler32_avx512_vnni_chunk
Expand Down
4 changes: 2 additions & 2 deletions lib/x86/crc32_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* incorrectly assumes that VPCLMULQDQ implies AVX-512:
* https://developercommunity.visualstudio.com/t/Compiler-incorrectly-assumes-VAES-and-VP/10578785?space=62&q=AVX512&sort=newest
*/
#if GCC_PREREQ(8, 1) || CLANG_PREREQ(6, 0, 0)
#if GCC_PREREQ(8, 1) || CLANG_PREREQ(6, 0, 10000000)
# define crc32_x86_vpclmulqdq_avx2 crc32_x86_vpclmulqdq_avx2
# define SUFFIX _vpclmulqdq_avx2
# define ATTRIBUTES _target_attribute("vpclmulqdq,pclmul,avx2")
Expand All @@ -77,7 +77,7 @@
# include "crc32_pclmul_template.h"
#endif

#if GCC_PREREQ(8, 1) || CLANG_PREREQ(6, 0, 0) || defined(_MSC_VER)
#if GCC_PREREQ(8, 1) || CLANG_PREREQ(6, 0, 10000000) || MSVC_PREREQ(1920)
/*
* VPCLMULQDQ/AVX512 implementation with 256-bit vectors. This takes advantage
* of some AVX-512 instructions but uses 256-bit vectors rather than 512-bit.
Expand Down

0 comments on commit 3fe22f5

Please sign in to comment.