diff options
Diffstat (limited to 'src/liblzma/check')
| -rw-r--r-- | src/liblzma/check/crc32_arm64.h | 5 | ||||
| -rw-r--r-- | src/liblzma/check/crc32_fast.c | 2 | ||||
| -rw-r--r-- | src/liblzma/check/crc64_fast.c | 10 | ||||
| -rw-r--r-- | src/liblzma/check/crc_common.h | 19 |
4 files changed, 20 insertions, 16 deletions
diff --git a/src/liblzma/check/crc32_arm64.h b/src/liblzma/check/crc32_arm64.h index fb0e8f0105a9..cce1131b336f 100644 --- a/src/liblzma/check/crc32_arm64.h +++ b/src/liblzma/check/crc32_arm64.h @@ -23,7 +23,8 @@ // If both versions are going to be built, we need runtime detection // to check if the instructions are supported. #if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED) -# if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO) +# if (defined(HAVE_GETAUXVAL) && defined(HAVE_HWCAP_CRC32)) \ + || defined(HAVE_ELF_AUX_INFO) # include <sys/auxv.h> # elif defined(_WIN32) # include <processthreadsapi.h> @@ -103,7 +104,7 @@ crc32_arch_optimized(const uint8_t *buf, size_t size, uint32_t crc) static inline bool is_arch_extension_supported(void) { -#if defined(HAVE_GETAUXVAL) +#if defined(HAVE_GETAUXVAL) && defined(HAVE_HWCAP_CRC32) return (getauxval(AT_HWCAP) & HWCAP_CRC32) != 0; #elif defined(HAVE_ELF_AUX_INFO) diff --git a/src/liblzma/check/crc32_fast.c b/src/liblzma/check/crc32_fast.c index 3c7cb95f57b7..6184e2b70e6b 100644 --- a/src/liblzma/check/crc32_fast.c +++ b/src/liblzma/check/crc32_fast.c @@ -2,7 +2,7 @@ /////////////////////////////////////////////////////////////////////////////// // -/// \file crc32.c +/// \file crc32_fast.c /// \brief CRC32 calculation // // Authors: Lasse Collin diff --git a/src/liblzma/check/crc64_fast.c b/src/liblzma/check/crc64_fast.c index 8a6770a431e8..792d0f9488bd 100644 --- a/src/liblzma/check/crc64_fast.c +++ b/src/liblzma/check/crc64_fast.c @@ -2,7 +2,7 @@ /////////////////////////////////////////////////////////////////////////////// // -/// \file crc64.c +/// \file crc64_fast.c /// \brief CRC64 calculation // // Authors: Lasse Collin @@ -146,14 +146,6 @@ crc64_dispatch(const uint8_t *buf, size_t size, uint64_t crc) extern LZMA_API(uint64_t) lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) { -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \ - && defined(_M_IX86) && defined(CRC64_ARCH_OPTIMIZED) - // VS2015-2022 might corrupt the ebx register on 32-bit x86 when - // the CLMUL code is enabled. This hack forces MSVC to store and - // restore ebx. This is only needed here, not in lzma_crc32(). - __asm mov ebx, ebx -#endif - #if defined(CRC64_GENERIC) && defined(CRC64_ARCH_OPTIMIZED) return crc64_func(buf, size, crc); diff --git a/src/liblzma/check/crc_common.h b/src/liblzma/check/crc_common.h index 7ea1e60b043b..4897dfee49ae 100644 --- a/src/liblzma/check/crc_common.h +++ b/src/liblzma/check/crc_common.h @@ -89,7 +89,8 @@ extern const uint64_t lzma_crc64_table[4][256]; // ARM64 // // Keep this in sync with changes to crc32_arm64.h -#if defined(_WIN32) || defined(HAVE_GETAUXVAL) \ +#if defined(_WIN32) \ + || (defined(HAVE_GETAUXVAL) && defined(HAVE_HWCAP_CRC32)) \ || defined(HAVE_ELF_AUX_INFO) \ || (defined(__APPLE__) && defined(HAVE_SYSCTLBYNAME)) # define CRC_ARM64_RUNTIME_DETECTION 1 @@ -134,10 +135,20 @@ extern const uint64_t lzma_crc64_table[4][256]; // built and runtime detection is used even if compiler flags // were set to allow CLMUL unconditionally. // - // - This doesn't work with MSVC as I don't know how to detect - // the features here. + // - The unconditional use doesn't work with MSVC as I don't know + // how to detect the features here. // -# if (defined(__SSSE3__) && defined(__SSE4_1__) && defined(__PCLMUL__) \ + // Don't enable CLMUL at all on old MSVC that targets 32-bit x86. + // There seems to be a compiler bug that produces broken code + // in optimized (Release) builds. It results in crashing tests. + // It is known that VS 2019 16.11 (MSVC 19.29.30158) is broken + // and that VS 2022 17.13 (MSVC 19.43.34808) works. +# if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 194334808 \ + && !defined(__INTEL_COMPILER) && !defined(__clang__) \ + && defined(_M_IX86) + // Old MSVC targeting 32-bit x86: Don't enable CLMUL at all. +# elif (defined(__SSSE3__) && defined(__SSE4_1__) \ + && defined(__PCLMUL__) \ && !defined(HAVE_CRC_X86_ASM)) \ || (defined(__e2k__) && __iset__ >= 6) # define CRC32_ARCH_OPTIMIZED 1 |
