aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check/crc_common.h
diff options
context:
space:
mode:
authorChenxi Mao <chenxi.mao2013@gmail.com>2024-01-09 17:23:11 +0800
committerJia Tan <jiat0218@gmail.com>2024-01-27 21:49:26 +0800
commit849d0f282a6a890c5cf5a0e0f02980b12d9ebb0f (patch)
tree2f8da4c7fcf61a8b9f6425f3075727c972e6bf94 /src/liblzma/check/crc_common.h
parentBump version number for 5.5.1alpha. (diff)
downloadxz-849d0f282a6a890c5cf5a0e0f02980b12d9ebb0f.tar.xz
Speed up CRC32 calculation on ARM64
The CRC32 instructions in ARM64 can calculate the CRC32 result for 8 bytes in a single operation, making the use of ARM64 instructions much faster compared to the general CRC32 algorithm. Optimized CRC32 will be enabled if ARM64 has CRC extension running on Linux. Signed-off-by: Chenxi Mao <chenxi.mao2013@gmail.com>
Diffstat (limited to 'src/liblzma/check/crc_common.h')
-rw-r--r--src/liblzma/check/crc_common.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/liblzma/check/crc_common.h b/src/liblzma/check/crc_common.h
index 417d88bb..7c7f098d 100644
--- a/src/liblzma/check/crc_common.h
+++ b/src/liblzma/check/crc_common.h
@@ -52,29 +52,33 @@
#undef CRC_GENERIC
#undef CRC_ARCH_OPTIMIZED
#undef CRC_X86_CLMUL
+#undef CRC32_ARM64
#undef CRC_USE_IFUNC
#undef CRC_USE_GENERIC_FOR_SMALL_INPUTS
-// If CLMUL cannot be used then only the generic slice-by-eight (CRC32)
-// or slice-by-four (CRC64) is built.
-#if !defined(HAVE_USABLE_CLMUL)
-# define CRC_GENERIC 1
-
// If CLMUL is allowed unconditionally in the compiler options then the
// generic version can be omitted. Note that this doesn't work with MSVC
// as I don't know how to detect the features here.
//
// NOTE: Keep this this in sync with crc32_table.c.
-#elif (defined(__SSSE3__) && defined(__SSE4_1__) && defined(__PCLMUL__)) \
+#if (defined(__SSSE3__) && defined(__SSE4_1__) && defined(__PCLMUL__)) \
|| (defined(__e2k__) && __iset__ >= 6)
# define CRC_ARCH_OPTIMIZED 1
# define CRC_X86_CLMUL 1
+#elif (defined(__aarch64__))
+# define CRC_ARCH_OPTIMIZED 1
+# define CRC32_ARM64 1
+// If CLMUL cannot be used then only the generic slice-by-eight (CRC32)
+// or slice-by-four (CRC64) is built.
+#elif !defined(HAVE_USABLE_CLMUL)
+# define CRC_GENERIC 1
// Otherwise build both and detect at runtime which version to use.
#else
# define CRC_GENERIC 1
# define CRC_ARCH_OPTIMIZED 1
# define CRC_X86_CLMUL 1
+# define CRC32_ARM64 1
# ifdef HAVE_FUNC_ATTRIBUTE_IFUNC
# define CRC_USE_IFUNC 1