diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-27 09:34:53 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-27 09:34:53 +0300 |
commit | b47d61d04fe59368a4d2c2de1bd04d9a8b5a20e5 (patch) | |
tree | 829506a641a2ba9e584d3675c83a3acf47f92f76 | |
parent | bb284e3fdbfb6fc20f703762a5437c57c5c9d597 (diff) | |
download | mariadb-git-b47d61d04fe59368a4d2c2de1bd04d9a8b5a20e5.tar.gz |
MDEV-23585: Fix HAVE_CLMUL_INSTRUCTION
MDEV-22641 in commit dec3f8ca69e5eb19a4be7a175d3834874c4d880b
refactored a SIMD implementation of CRC-32 for the ISO 3309 polynomial
that uses the IA-32/AMD64 carry-less multiplication (pclmul)
instructions. The code was previously only available in Mariabackup;
it was changed to be a general replacement of the zlib crc32().
There exist AMD64 systems where CMAKE_SYSTEM_PROCESSOR matches
the pattern i[36]86 but not x86_64 or amd64. This would cause a
link failure, because mysys/checksum.c would basically assume that
the compiler support for instruction is always available on GCC-compatible
compilers on AMD64.
Furthermore, we were unnecessarily disabling the SIMD acceleration
for 32-bit executables.
Note: Until MDEV-22749 has been implemented, the PCLMUL instruction
will not be used on Microsoft Windows.
Closes: #1660
-rw-r--r-- | config.h.cmake | 2 | ||||
-rw-r--r-- | mysys/CMakeLists.txt | 2 | ||||
-rw-r--r-- | mysys/checksum.c | 3 | ||||
-rw-r--r-- | mysys/crc32/crc32_x86.c | 3 |
4 files changed, 4 insertions, 6 deletions
diff --git a/config.h.cmake b/config.h.cmake index ff0a039b3ac..0de5c2be3e0 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -102,6 +102,8 @@ /* Libraries */ #cmakedefine HAVE_LIBWRAP 1 #cmakedefine HAVE_SYSTEMD 1 + +#cmakedefine HAVE_CLMUL_INSTRUCTION 1 #cmakedefine HAVE_CRC32_VPMSUM 1 /* Support ARMv8 crc + crypto */ diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 14a4ea9e9bb..3122decfde1 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -58,7 +58,7 @@ IF (WIN32) my_win_popen.cc) ENDIF() -IF(NOT MSVC AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64") +IF(NOT MSVC AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|i[36]86") #Check for PCLMUL instruction (x86) CHECK_C_SOURCE_COMPILES(" int main() diff --git a/mysys/checksum.c b/mysys/checksum.c index 948b9be6164..6e6633600a9 100644 --- a/mysys/checksum.c +++ b/mysys/checksum.c @@ -30,8 +30,7 @@ static unsigned int my_crc32_zlib(unsigned int crc, const void *data, my_crc32_t my_checksum= my_crc32_zlib; #endif -#if __GNUC__ >= 4 && defined(__x86_64__) - +#ifdef HAVE_CLMUL_INSTRUCTION extern int crc32_pclmul_enabled(); extern unsigned int crc32_pclmul(unsigned int, const void *, size_t); diff --git a/mysys/crc32/crc32_x86.c b/mysys/crc32/crc32_x86.c index 3f176a6c145..608ba3927c7 100644 --- a/mysys/crc32/crc32_x86.c +++ b/mysys/crc32/crc32_x86.c @@ -57,8 +57,6 @@ typedef uint8_t byte; # define _gcry_bswap32 __builtin_bswap32 -#if __GNUC__ >= 4 && defined(__x86_64__) - #if defined(_GCRY_GCC_VERSION) && _GCRY_GCC_VERSION >= 40400 /* 4.4 */ /* Prevent compiler from issuing SSE instructions between asm blocks. */ # pragma GCC target("no-sse") @@ -542,4 +540,3 @@ unsigned int crc32_pclmul(unsigned int crc32, const void *buf, size_t len) crc32_intel_pclmul(&crc32, buf, len); return ~crc32; } -#endif |