aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2023-10-18 19:57:10 +0800
committerJia Tan <jiat0218@gmail.com>2023-10-18 23:54:41 +0800
commit1c8884f0af28b3a4690bb573cdf3240a8ec73416 (patch)
tree324c32b0dc4d7cd3217a3d394965772204b4ed80
parentliblzma: CRC_USE_GENERIC_FOR_SMALL_INPUTS cannot be used with ifunc. (diff)
downloadxz-1c8884f0af28b3a4690bb573cdf3240a8ec73416.tar.xz
liblzma: Set the MSVC optimization fix to only cover lzma_crc64_clmul().
After testing a 32-bit Release build on MSVC, only lzma_crc64_clmul() has the bug. crc_simd_body() and lzma_crc32_clmul() do not need the optimizations disabled.
-rw-r--r--src/liblzma/check/crc_clmul.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/liblzma/check/crc_clmul.c b/src/liblzma/check/crc_clmul.c
index 404adb82..b90f43e3 100644
--- a/src/liblzma/check/crc_clmul.c
+++ b/src/liblzma/check/crc_clmul.c
@@ -42,21 +42,6 @@
MASK_H(in, mask, high)
-// MSVC (VS2015 - VS2022) produces bad 32-bit x86 code from the CLMUL CRC
-// code when optimizations are enabled (release build). According to the bug
-// report, the ebx register is corrupted and the calculated result is wrong.
-// Trying to workaround the problem with "__asm mov ebx, ebx" didn't help.
-// The following pragma works and performance is still good. x86-64 builds
-// aren't affected by this problem.
-//
-// NOTE: Another pragma after lzma_crc64_clmul() restores the optimizations.
-// If the #if condition here is updated, the other one must be updated too.
-#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \
- && defined(_M_IX86)
-# pragma optimize("g", off)
-#endif
-
-
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)
__attribute__((__target__("ssse3,sse4.1,pclmul")))
#endif
@@ -314,6 +299,21 @@ calc_hi(uint64_t poly, uint64_t a)
#ifdef HAVE_CHECK_CRC64
+// MSVC (VS2015 - VS2022) produces bad 32-bit x86 code from the CLMUL CRC
+// code when optimizations are enabled (release build). According to the bug
+// report, the ebx register is corrupted and the calculated result is wrong.
+// Trying to workaround the problem with "__asm mov ebx, ebx" didn't help.
+// The following pragma works and performance is still good. x86-64 builds
+// and CRC32 CLMUL aren't affected by this problem. The problem does not
+// happen in crc_simd_body() either (which is shared with CRC32 CLMUL anyway).
+//
+// NOTE: Another pragma after lzma_crc64_clmul() restores the optimizations.
+// If the #if condition here is updated, the other one must be updated too.
+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \
+ && defined(_M_IX86)
+# pragma optimize("g", off)
+#endif
+
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)
__attribute__((__target__("ssse3,sse4.1,pclmul")))
#endif