From: Nathan Moinvaziri Date: Fri, 19 Dec 2025 00:17:18 +0000 (-0800) Subject: Refactor crc32_fold functions into single crc32_copy X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1fed4ba05a49fd3b5ca8743461d9782f70fa820;p=thirdparty%2Fzlib-ng.git Refactor crc32_fold functions into single crc32_copy --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0476b9af4..f4ebacfd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1387,7 +1387,6 @@ set(ZLIB_ALL_FALLBACK_SRCS arch/generic/chunkset_c.c arch/generic/compare256_c.c arch/generic/crc32_braid_c.c - arch/generic/crc32_fold_c.c arch/generic/slide_hash_c.c ) @@ -1399,7 +1398,6 @@ elseif(BASEARCH_X86_FOUND AND ARCH_64BIT AND WITH_SSE2) list(APPEND ZLIB_GENERIC_SRCS arch/generic/adler32_c.c arch/generic/crc32_braid_c.c - arch/generic/crc32_fold_c.c ) # x86_64 does not need compare256 fallback if we have BUILTIN_CTZ diff --git a/Makefile.in b/Makefile.in index 19fced000..5eff55521 100644 --- a/Makefile.in +++ b/Makefile.in @@ -79,7 +79,6 @@ OBJZ = \ arch/generic/chunkset_c.o \ arch/generic/compare256_c.o \ arch/generic/crc32_braid_c.o \ - arch/generic/crc32_fold_c.o \ arch/generic/slide_hash_c.o \ adler32.o \ compress.o \ @@ -118,7 +117,6 @@ PIC_OBJZ = \ arch/generic/chunkset_c.lo \ arch/generic/compare256_c.lo \ arch/generic/crc32_braid_c.lo \ - arch/generic/crc32_fold_c.lo \ arch/generic/slide_hash_c.lo \ adler32.lo \ compress.lo \ diff --git a/arch/arm/arm_functions.h b/arch/arm/arm_functions.h index 1dbb3fb55..50dfc6c29 100644 --- a/arch/arm/arm_functions.h +++ b/arch/arm/arm_functions.h @@ -21,8 +21,7 @@ void inflate_fast_neon(PREFIX3(stream) *strm, uint32_t start); #ifdef ARM_CRC32 uint32_t crc32_armv8(uint32_t crc, const uint8_t *buf, size_t len); -void crc32_fold_copy_armv8(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len); -void crc32_fold_armv8(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc); +uint32_t crc32_copy_armv8(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #endif #ifdef ARM_SIMD @@ -61,10 +60,8 @@ void slide_hash_armv6(deflate_state *s); # if (defined(ARM_CRC32) && defined(__ARM_FEATURE_CRC32)) # undef native_crc32 # define native_crc32 crc32_armv8 -# undef native_crc32_fold -# define native_crc32_fold crc32_fold_armv8 -# undef native_crc32_fold_copy -# define native_crc32_fold_copy crc32_fold_copy_armv8 +# undef native_crc32_copy +# define native_crc32_copy crc32_copy_armv8 # endif #endif diff --git a/arch/arm/crc32_armv8.c b/arch/arm/crc32_armv8.c index 3fa36a121..18e315519 100644 --- a/arch/arm/crc32_armv8.c +++ b/arch/arm/crc32_armv8.c @@ -72,15 +72,9 @@ Z_INTERNAL Z_TARGET_CRC uint32_t crc32_armv8(uint32_t crc, const uint8_t *buf, s return c; } -/* Note: Based on generic crc32_fold_* implementation with functable call replaced by direct call. */ -Z_INTERNAL Z_TARGET_CRC void crc32_fold_copy_armv8(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) { - crc->value = crc32_armv8(crc->value, src, len); +Z_INTERNAL Z_TARGET_CRC uint32_t crc32_copy_armv8(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_armv8(crc, src, len); memcpy(dst, src, len); + return crc; } - -Z_INTERNAL Z_TARGET_CRC void crc32_fold_armv8(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) { - Z_UNUSED(init_crc); - crc->value = crc32_armv8(crc->value, src, len); -} - #endif diff --git a/arch/generic/Makefile.in b/arch/generic/Makefile.in index 46e59894d..07a168f2f 100644 --- a/arch/generic/Makefile.in +++ b/arch/generic/Makefile.in @@ -18,7 +18,6 @@ all: \ compare256_c.o compare256_c.lo \ crc32_braid_c.o crc32_braid_c.lo \ crc32_chorba_c.o crc32_chorba_c.lo \ - crc32_fold_c.o crc32_fold_c.lo \ slide_hash_c.o slide_hash_c.lo @@ -52,12 +51,6 @@ crc32_chorba_c.o: $(SRCDIR)/crc32_chorba_c.c $(SRCTOP)/zbuild.h $(SRCTOP)/crc32 crc32_chorba_c.lo: $(SRCDIR)/crc32_chorba_c.c $(SRCTOP)/zbuild.h $(SRCTOP)/crc32_braid_p.h $(SRCTOP)/crc32_braid_tbl.h $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_chorba_c.c -crc32_fold_c.o: $(SRCDIR)/crc32_fold_c.c $(SRCTOP)/zbuild.h $(SRCTOP)/functable.h - $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_fold_c.c - -crc32_fold_c.lo: $(SRCDIR)/crc32_fold_c.c $(SRCTOP)/zbuild.h $(SRCTOP)/functable.h - $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_fold_c.c - slide_hash_c.o: $(SRCDIR)/slide_hash_c.c $(SRCTOP)/zbuild.h $(SRCTOP)/deflate.h $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_hash_c.c diff --git a/arch/generic/crc32_braid_c.c b/arch/generic/crc32_braid_c.c index 40c561059..71f2ac43f 100644 --- a/arch/generic/crc32_braid_c.c +++ b/arch/generic/crc32_braid_c.c @@ -212,11 +212,17 @@ Z_INTERNAL uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t return c; } -Z_INTERNAL uint32_t crc32_braid(uint32_t c, const uint8_t *buf, size_t len) { - c = (~c) & 0xffffffff; +Z_INTERNAL uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, size_t len) { + crc = (~crc) & 0xffffffff; - c = crc32_braid_internal(c, buf, len); + crc = crc32_braid_internal(crc, buf, len); /* Return the CRC, post-conditioned. */ - return c ^ 0xffffffff; + return crc ^ 0xffffffff; +} + +Z_INTERNAL uint32_t crc32_copy_braid(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_braid(crc, src, len); + memcpy(dst, src, len); + return crc; } diff --git a/arch/generic/crc32_chorba_c.c b/arch/generic/crc32_chorba_c.c index 279aa747c..303a516a0 100644 --- a/arch/generic/crc32_chorba_c.c +++ b/arch/generic/crc32_chorba_c.c @@ -1479,3 +1479,9 @@ Z_INTERNAL uint32_t crc32_chorba(uint32_t crc, const uint8_t *buf, size_t len) { /* Return the CRC, post-conditioned. */ return c ^ 0xffffffff; } + +uint32_t crc32_copy_chorba(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_chorba(crc, src, len); + memcpy(dst, src, len); + return crc; +} diff --git a/arch/generic/crc32_fold_c.c b/arch/generic/crc32_fold_c.c deleted file mode 100644 index 43930e97c..000000000 --- a/arch/generic/crc32_fold_c.c +++ /dev/null @@ -1,31 +0,0 @@ -/* crc32_fold.c -- crc32 folding interface - * Copyright (C) 2021 Nathan Moinvaziri - * For conditions of distribution and use, see copyright notice in zlib.h - */ -#include "zbuild.h" -#include "zutil.h" -#include "functable.h" -#include "crc32.h" - -Z_INTERNAL uint32_t crc32_fold_reset_c(crc32_fold *crc) { - crc->value = CRC32_INITIAL_VALUE; - return crc->value; -} - -Z_INTERNAL void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) { - crc->value = FUNCTABLE_CALL(crc32)(crc->value, src, len); - memcpy(dst, src, len); -} - -Z_INTERNAL void crc32_fold_c(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) { - /* Note: while this is basically the same thing as the vanilla CRC function, we still need - * a functable entry for it so that we can generically dispatch to this function with the - * same arguments for the versions that _do_ do a folding CRC but we don't want a copy. The - * init_crc is an unused argument in this context */ - Z_UNUSED(init_crc); - crc->value = FUNCTABLE_CALL(crc32)(crc->value, src, len); -} - -Z_INTERNAL uint32_t crc32_fold_final_c(crc32_fold *crc) { - return crc->value; -} diff --git a/arch/generic/generic_functions.h b/arch/generic/generic_functions.h index f95fe4bb0..adf3a2681 100644 --- a/arch/generic/generic_functions.h +++ b/arch/generic/generic_functions.h @@ -11,10 +11,8 @@ typedef uint32_t (*adler32_func)(uint32_t adler, const uint8_t *buf, size_t len); typedef uint32_t (*compare256_func)(const uint8_t *src0, const uint8_t *src1); -typedef uint32_t (*crc32_func)(uint32_t crc32, const uint8_t *buf, size_t len); -typedef uint32_t (*crc32_fold_reset_func)(crc32_fold *crc); -typedef void (*crc32_fold_copy_func)(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len); -typedef uint32_t (*crc32_fold_final_func)(crc32_fold *crc); +typedef uint32_t (*crc32_func)(uint32_t crc, const uint8_t *buf, size_t len); +typedef uint32_t (*crc32_copy_func)(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); typedef void (*slide_hash_func)(deflate_state *s); @@ -25,8 +23,9 @@ uint8_t* chunkmemset_safe_c(uint8_t *out, uint8_t *from, unsigned len, unsigned uint32_t compare256_c(const uint8_t *src0, const uint8_t *src1); -uint32_t crc32_braid(uint32_t c, const uint8_t *buf, size_t len); +uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, size_t len); uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t len); +uint32_t crc32_copy_braid(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #ifndef WITHOUT_CHORBA uint32_t crc32_chorba(uint32_t crc, const uint8_t *buf, size_t len); @@ -34,13 +33,9 @@ uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t len); uint32_t crc32_chorba_32768_nondestructive (uint32_t crc, const uint64_t* buf, size_t len); uint32_t crc32_chorba_small_nondestructive (uint32_t crc, const uint64_t* buf, size_t len); uint32_t crc32_chorba_small_nondestructive_32bit (uint32_t crc, const uint32_t* buf, size_t len); + uint32_t crc32_copy_chorba(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #endif -uint32_t crc32_fold_reset_c(crc32_fold *crc); -void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len); -void crc32_fold_c(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc); -uint32_t crc32_fold_final_c(crc32_fold *crc); - void inflate_fast_c(PREFIX3(stream) *strm, uint32_t start); uint32_t longest_match_c(deflate_state *const s, uint32_t cur_match); @@ -55,13 +50,11 @@ void slide_hash_c(deflate_state *s); # define native_chunkmemset_safe chunkmemset_safe_c #ifndef WITHOUT_CHORBA # define native_crc32 crc32_chorba +# define native_crc32_copy crc32_copy_chorba #else # define native_crc32 crc32_braid +# define native_crc32_copy crc32_copy_braid #endif -# define native_crc32_fold crc32_fold_c -# define native_crc32_fold_copy crc32_fold_copy_c -# define native_crc32_fold_final crc32_fold_final_c -# define native_crc32_fold_reset crc32_fold_reset_c # define native_inflate_fast inflate_fast_c # define native_slide_hash slide_hash_c # define native_longest_match longest_match_c diff --git a/arch/loongarch/crc32_la.c b/arch/loongarch/crc32_la.c index 38c63eea0..0d8effe03 100644 --- a/arch/loongarch/crc32_la.c +++ b/arch/loongarch/crc32_la.c @@ -72,15 +72,9 @@ Z_INTERNAL uint32_t crc32_loongarch64(uint32_t crc, const uint8_t *buf, size_t l return c; } -/* Note: Based on generic crc32_fold_* implementation with functable call replaced by direct call. */ -Z_INTERNAL void crc32_fold_copy_loongarch64(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) { - crc->value = crc32_loongarch64(crc->value, src, len); +Z_INTERNAL uint32_t crc32_copy_loongarch64(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_loongarch64(crc, src, len); memcpy(dst, src, len); + return crc; } - -Z_INTERNAL void crc32_fold_loongarch64(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) { - Z_UNUSED(init_crc); - crc->value = crc32_loongarch64(crc->value, src, len); -} - #endif diff --git a/arch/loongarch/loongarch_functions.h b/arch/loongarch/loongarch_functions.h index 2ddb9041f..939a3a03e 100644 --- a/arch/loongarch/loongarch_functions.h +++ b/arch/loongarch/loongarch_functions.h @@ -10,8 +10,7 @@ #ifdef LOONGARCH_CRC uint32_t crc32_loongarch64(uint32_t crc, const uint8_t *buf, size_t len); -void crc32_fold_copy_loongarch64(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len); -void crc32_fold_loongarch64(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc); +uint32_t crc32_copy_loongarch64(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #endif #ifdef LOONGARCH_LSX @@ -45,10 +44,8 @@ void inflate_fast_lasx(PREFIX3(stream) *strm, uint32_t start); # if defined(LOONGARCH_CRC) # undef native_crc32 # define native_crc32 crc32_loongarch64 -# undef native_crc32_fold -# define native_crc32_fold crc32_fold_loongarch64 -# undef native_crc32_fold_copy -# define native_crc32_fold_copy crc32_fold_copy_loongarch64 +# undef native_crc32_copy +# define native_crc32_copy crc32_copy_loongarch64 # endif # if defined(LOONGARCH_LSX) && defined(__loongarch_sx) # undef native_adler32 diff --git a/arch/power/crc32_power8.c b/arch/power/crc32_power8.c index 28c59b663..20ea89ed2 100644 --- a/arch/power/crc32_power8.c +++ b/arch/power/crc32_power8.c @@ -83,6 +83,12 @@ out: return crc; } +Z_INTERNAL uint32_t crc32_copy_power8(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_power8(crc, src, len); + memcpy(dst, src, len); + return crc; +} + /* When we have a load-store in a single-dispatch group and address overlap * such that forward is not allowed (load-hit-store) the group must be flushed. * A group ending NOP prevents the flush. diff --git a/arch/power/power_functions.h b/arch/power/power_functions.h index d2291516b..fe3a64821 100644 --- a/arch/power/power_functions.h +++ b/arch/power/power_functions.h @@ -16,6 +16,7 @@ void slide_hash_vmx(deflate_state *s); uint32_t adler32_power8(uint32_t adler, const uint8_t *buf, size_t len); uint8_t* chunkmemset_safe_power8(uint8_t *out, uint8_t *from, unsigned len, unsigned left); uint32_t crc32_power8(uint32_t crc, const uint8_t *buf, size_t len); +uint32_t crc32_copy_power8(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); void slide_hash_power8(deflate_state *s); void inflate_fast_power8(PREFIX3(stream) *strm, uint32_t start); #endif @@ -49,6 +50,8 @@ uint32_t longest_match_slow_power9(deflate_state *const s, uint32_t cur_match); # if defined(POWER8_VSX_CRC32) && defined(_ARCH_PWR8) && defined(__VSX__) # undef native_crc32 # define native_crc32 crc32_power8 +# undef native_crc32_copy +# define native_crc32_copy crc32_copy_power8 # endif // Power9 # if defined(POWER9) && defined(_ARCH_PWR9) diff --git a/arch/riscv/crc32_zbc.c b/arch/riscv/crc32_zbc.c index e3f3c7164..71bd70a4e 100644 --- a/arch/riscv/crc32_zbc.c +++ b/arch/riscv/crc32_zbc.c @@ -97,4 +97,9 @@ Z_INTERNAL uint32_t crc32_riscv64_zbc(uint32_t crc, const uint8_t *buf, return crc ^ 0xFFFFFFFF; } +Z_INTERNAL uint32_t crc32_copy_riscv64_zbc(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_riscv64_zbc(crc, src, len); + memcpy(dst, src, len); + return crc; +} #endif diff --git a/arch/riscv/riscv_functions.h b/arch/riscv/riscv_functions.h index 9f0f3880c..e87989cca 100644 --- a/arch/riscv/riscv_functions.h +++ b/arch/riscv/riscv_functions.h @@ -23,6 +23,7 @@ void inflate_fast_rvv(PREFIX3(stream) *strm, uint32_t start); #ifdef RISCV_CRC32_ZBC uint32_t crc32_riscv64_zbc(uint32_t crc, const uint8_t *buf, size_t len); +uint32_t crc32_copy_riscv64_zbc(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #endif #ifdef DISABLE_RUNTIME_CPU_DETECTION @@ -50,6 +51,8 @@ uint32_t crc32_riscv64_zbc(uint32_t crc, const uint8_t *buf, size_t len); # if (defined(RISCV_CRC32_ZBC) && defined (__riscv_zbc)) # undef native_crc32 # define native_crc32 crc32_riscv64_zbc +# undef native_crc32_copy +# define native_crc32_copy crc32_copy_riscv64_zbc # endif #endif diff --git a/arch/s390/crc32-vx.c b/arch/s390/crc32-vx.c index 155eee494..10105990d 100644 --- a/arch/s390/crc32-vx.c +++ b/arch/s390/crc32-vx.c @@ -220,3 +220,9 @@ uint32_t Z_INTERNAL crc32_s390_vx(uint32_t crc, const unsigned char *buf, size_t return crc; } + +Z_INTERNAL uint32_t crc32_copy_s390_vx(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_s390_vx(crc, src, len); + memcpy(dst, src, len); + return crc; +} diff --git a/arch/s390/s390_functions.h b/arch/s390/s390_functions.h index 2c43a5062..7de83abb6 100644 --- a/arch/s390/s390_functions.h +++ b/arch/s390/s390_functions.h @@ -7,6 +7,7 @@ #ifdef S390_CRC32_VX uint32_t crc32_s390_vx(uint32_t crc, const uint8_t *buf, size_t len); +uint32_t crc32_copy_s390_vx(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #ifdef __clang__ # if ((__clang_major__ == 18) || (__clang_major__ == 19 && (__clang_minor__ < 1 || (__clang_minor__ == 1 && __clang_patchlevel__ < 2)))) @@ -21,6 +22,8 @@ uint32_t crc32_s390_vx(uint32_t crc, const uint8_t *buf, size_t len); # if defined(S390_CRC32_VX) && defined(__zarch__) && __ARCH__ >= 11 && defined(__VX__) # undef native_crc32 # define native_crc32 crc32_s390_vx +# undef native_crc32_copy +# define native_crc32_copy crc32_copy_s390_vx # endif #endif diff --git a/arch/x86/chorba_sse2.c b/arch/x86/chorba_sse2.c index f79a5ac00..95da8e99b 100644 --- a/arch/x86/chorba_sse2.c +++ b/arch/x86/chorba_sse2.c @@ -873,4 +873,10 @@ Z_INTERNAL uint32_t crc32_chorba_sse2(uint32_t crc, const uint8_t *buf, size_t l /* Return the CRC, post-conditioned. */ return c ^ 0xffffffff; } + +Z_INTERNAL uint32_t crc32_copy_chorba_sse2(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_chorba_sse2(crc, src, len); + memcpy(dst, src, len); + return crc; +} #endif diff --git a/arch/x86/chorba_sse41.c b/arch/x86/chorba_sse41.c index a7568a280..9f2b65a3e 100644 --- a/arch/x86/chorba_sse41.c +++ b/arch/x86/chorba_sse41.c @@ -333,4 +333,10 @@ Z_INTERNAL uint32_t crc32_chorba_sse41(uint32_t crc, const uint8_t *buf, size_t /* Return the CRC, post-conditioned. */ return c ^ 0xffffffff; } + +Z_INTERNAL uint32_t crc32_copy_chorba_sse41(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { + crc = crc32_chorba_sse41(crc, src, len); + memcpy(dst, src, len); + return crc; +} #endif diff --git a/arch/x86/crc32_fold_pclmulqdq_tpl.h b/arch/x86/crc32_fold_pclmulqdq_tpl.h index f4f06302c..e7e57c546 100644 --- a/arch/x86/crc32_fold_pclmulqdq_tpl.h +++ b/arch/x86/crc32_fold_pclmulqdq_tpl.h @@ -394,6 +394,18 @@ static inline uint32_t crc32_small(uint32_t crc, const uint8_t *buf, size_t len) return c ^ 0xffffffff; } +static inline uint32_t crc32_small_copy(uint32_t crc, uint8_t *dst, const uint8_t *buf, size_t len) { + uint32_t c = (~crc) & 0xffffffff; + + while (len) { + len--; + *dst++ = *buf; + CRC_DO1; + } + + return c ^ 0xffffffff; +} + static inline void crc32_fold_load(__m128i *fold, __m128i *fold0, __m128i *fold1, __m128i *fold2, __m128i *fold3) { *fold0 = _mm_load_si128(fold + 0); *fold1 = _mm_load_si128(fold + 1); diff --git a/arch/x86/crc32_pclmulqdq.c b/arch/x86/crc32_pclmulqdq.c index 428f5554e..94c9789b7 100644 --- a/arch/x86/crc32_pclmulqdq.c +++ b/arch/x86/crc32_pclmulqdq.c @@ -21,31 +21,27 @@ #include "crc32_fold_pclmulqdq_tpl.h" -Z_INTERNAL uint32_t crc32_fold_pclmulqdq_reset(crc32_fold *crc) { - return crc32_fold_reset(crc); -} - -Z_INTERNAL uint32_t crc32_fold_pclmulqdq_final(crc32_fold *crc) { - return crc32_fold_final(crc); -} - -Z_INTERNAL void crc32_fold_pclmulqdq(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) { - crc32_fold_copy(crc, NULL, src, len, init_crc, 0); -} +Z_INTERNAL uint32_t crc32_pclmulqdq(uint32_t crc, const uint8_t *buf, size_t len) { + /* For lens smaller than ~12, crc32_small method is faster. + * But there are also minimum requirements for the pclmul functions due to alignment */ + if (len < 16) + return crc32_small(crc, buf, len); -Z_INTERNAL void crc32_fold_pclmulqdq_copy(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) { - crc32_fold_copy(crc, dst, src, len, 0, 1); + crc32_fold ALIGNED_(16) crc_state; + crc32_fold_reset(&crc_state); + crc32_fold_copy(&crc_state, NULL, buf, len, crc, 0); + return crc32_fold_final(&crc_state); } -Z_INTERNAL uint32_t crc32_pclmulqdq(uint32_t crc32, const uint8_t *buf, size_t len) { +Z_INTERNAL uint32_t crc32_copy_pclmulqdq(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { /* For lens smaller than ~12, crc32_small method is faster. * But there are also minimum requirements for the pclmul functions due to alignment */ if (len < 16) - return crc32_small(crc32, buf, len); + return crc32_small_copy(crc, dst, src, len); crc32_fold ALIGNED_(16) crc_state; crc32_fold_reset(&crc_state); - crc32_fold_copy(&crc_state, NULL, buf, len, crc32, 0); + crc32_fold_copy(&crc_state, dst, src, len, crc, 1); return crc32_fold_final(&crc_state); } #endif diff --git a/arch/x86/crc32_vpclmulqdq.c b/arch/x86/crc32_vpclmulqdq.c index a3567e94d..92109efe9 100644 --- a/arch/x86/crc32_vpclmulqdq.c +++ b/arch/x86/crc32_vpclmulqdq.c @@ -8,32 +8,27 @@ #define X86_VPCLMULQDQ #include "crc32_fold_pclmulqdq_tpl.h" -Z_INTERNAL uint32_t crc32_fold_vpclmulqdq_reset(crc32_fold *crc) { - return crc32_fold_reset(crc); -} - -Z_INTERNAL uint32_t crc32_fold_vpclmulqdq_final(crc32_fold *crc) { - return crc32_fold_final(crc); -} - -Z_INTERNAL void crc32_fold_vpclmulqdq(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc) { - crc32_fold_copy(crc, NULL, src, len, init_crc, 0); -} +Z_INTERNAL uint32_t crc32_vpclmulqdq(uint32_t crc, const uint8_t *buf, size_t len) { + /* For lens smaller than ~12, crc32_small method is faster. + * But there are also minimum requirements for the pclmul functions due to alignment */ + if (len < 16) + return crc32_small(crc, buf, len); -Z_INTERNAL void crc32_fold_vpclmulqdq_copy(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) { - crc32_fold_copy(crc, dst, src, len, 0, 1); + crc32_fold ALIGNED_(16) crc_state; + crc32_fold_reset(&crc_state); + crc32_fold_copy(&crc_state, NULL, buf, len, crc, 0); + return crc32_fold_final(&crc_state); } -Z_INTERNAL uint32_t crc32_vpclmulqdq(uint32_t crc32, const uint8_t *buf, size_t len) { +Z_INTERNAL uint32_t crc32_copy_vpclmulqdq(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { /* For lens smaller than ~12, crc32_small method is faster. * But there are also minimum requirements for the pclmul functions due to alignment */ if (len < 16) - return crc32_small(crc32, buf, len); + return crc32_small_copy(crc, dst, src, len); crc32_fold ALIGNED_(16) crc_state; crc32_fold_reset(&crc_state); - crc32_fold_copy(&crc_state, NULL, buf, len, crc32, 0); + crc32_fold_copy(&crc_state, dst, src, len, crc, 1); return crc32_fold_final(&crc_state); } - #endif diff --git a/arch/x86/x86_functions.h b/arch/x86/x86_functions.h index b97bee535..0f9aa1824 100644 --- a/arch/x86/x86_functions.h +++ b/arch/x86/x86_functions.h @@ -25,7 +25,8 @@ uint8_t* chunkmemset_safe_sse2(uint8_t *out, uint8_t *from, unsigned len, unsign void slide_hash_sse2(deflate_state *s); void inflate_fast_sse2(PREFIX3(stream)* strm, uint32_t start); # if !defined(WITHOUT_CHORBA_SSE) - uint32_t crc32_chorba_sse2(uint32_t crc32, const uint8_t *buf, size_t len); + uint32_t crc32_chorba_sse2(uint32_t crc, const uint8_t *buf, size_t len); + uint32_t crc32_copy_chorba_sse2(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); uint32_t chorba_small_nondestructive_sse2(uint32_t c, const uint64_t *aligned_buf, size_t aligned_len); # endif #endif @@ -37,7 +38,8 @@ void inflate_fast_ssse3(PREFIX3(stream) *strm, uint32_t start); #endif #if defined(X86_SSE41) && !defined(WITHOUT_CHORBA_SSE) - uint32_t crc32_chorba_sse41(uint32_t crc32, const uint8_t *buf, size_t len); + uint32_t crc32_chorba_sse41(uint32_t crc, const uint8_t *buf, size_t len); + uint32_t crc32_copy_chorba_sse41(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #endif #ifdef X86_SSE42 @@ -74,18 +76,12 @@ uint32_t adler32_copy_avx512_vnni(uint32_t adler, uint8_t *dst, const uint8_t *s #endif #ifdef X86_PCLMULQDQ_CRC -uint32_t crc32_fold_pclmulqdq_reset(crc32_fold *crc); -void crc32_fold_pclmulqdq_copy(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len); -void crc32_fold_pclmulqdq(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc); -uint32_t crc32_fold_pclmulqdq_final(crc32_fold *crc); -uint32_t crc32_pclmulqdq(uint32_t crc32, const uint8_t *buf, size_t len); +uint32_t crc32_pclmulqdq(uint32_t crc, const uint8_t *buf, size_t len); +uint32_t crc32_copy_pclmulqdq(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #endif #ifdef X86_VPCLMULQDQ_CRC -uint32_t crc32_fold_vpclmulqdq_reset(crc32_fold *crc); -void crc32_fold_vpclmulqdq_copy(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len); -void crc32_fold_vpclmulqdq(crc32_fold *crc, const uint8_t *src, size_t len, uint32_t init_crc); -uint32_t crc32_fold_vpclmulqdq_final(crc32_fold *crc); -uint32_t crc32_vpclmulqdq(uint32_t crc32, const uint8_t *buf, size_t len); +uint32_t crc32_vpclmulqdq(uint32_t crc, const uint8_t *buf, size_t len); +uint32_t crc32_copy_vpclmulqdq(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); #endif #ifdef DISABLE_RUNTIME_CPU_DETECTION @@ -123,6 +119,8 @@ uint32_t crc32_vpclmulqdq(uint32_t crc32, const uint8_t *buf, size_t len); # if defined(X86_SSE41) && defined(__SSE4_1__) && !defined(WITHOUT_CHORBA_SSE) # undef native_crc32 # define native_crc32 crc32_chorba_sse41 +# undef native_crc32_copy +# define native_crc32_copy crc32_copy_chorba_sse41 # endif // X86 - SSE4.2 # if defined(X86_SSE42) && defined(__SSE4_2__) @@ -133,14 +131,8 @@ uint32_t crc32_vpclmulqdq(uint32_t crc32, const uint8_t *buf, size_t len); # if defined(X86_PCLMULQDQ_CRC) && defined(__PCLMUL__) # undef native_crc32 # define native_crc32 crc32_pclmulqdq -# undef native_crc32_fold -# define native_crc32_fold crc32_fold_pclmulqdq -# undef native_crc32_fold_copy -# define native_crc32_fold_copy crc32_fold_pclmulqdq_copy -# undef native_crc32_fold_final -# define native_crc32_fold_final crc32_fold_pclmulqdq_final -# undef native_crc32_fold_reset -# define native_crc32_fold_reset crc32_fold_pclmulqdq_reset +# undef native_crc32_copy +# define native_crc32_copy crc32_copy_pclmulqdq # endif // X86 - AVX2 # if defined(X86_AVX2) && defined(__AVX2__) @@ -192,14 +184,8 @@ uint32_t crc32_vpclmulqdq(uint32_t crc32, const uint8_t *buf, size_t len); # if defined(__PCLMUL__) && defined(__AVX512F__) && defined(__VPCLMULQDQ__) # undef native_crc32 # define native_crc32 crc32_vpclmulqdq -# undef native_crc32_fold -# define native_crc32_fold crc32_fold_vpclmulqdq -# undef native_crc32_fold_copy -# define native_crc32_fold_copy crc32_fold_vpclmulqdq_copy -# undef native_crc32_fold_final -# define native_crc32_fold_final crc32_fold_vpclmulqdq_final -# undef native_crc32_fold_reset -# define native_crc32_fold_reset crc32_fold_vpclmulqdq_reset +# undef native_crc32_copy +# define native_crc32_copy crc32_copy_vpclmulqdq # endif # endif #endif diff --git a/deflate.c b/deflate.c index b6468f573..dcd2e62a4 100644 --- a/deflate.c +++ b/deflate.c @@ -521,7 +521,7 @@ int32_t Z_EXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { #ifdef GZIP if (s->wrap == 2) { - strm->adler = FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold); + strm->adler = CRC32_INITIAL_VALUE; } else #endif strm->adler = ADLER32_INITIAL_VALUE; @@ -847,7 +847,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { #ifdef GZIP if (s->status == GZIP_STATE) { /* gzip header */ - FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold); + strm->adler = CRC32_INITIAL_VALUE; put_byte(s, 31); put_byte(s, 139); put_byte(s, 8); @@ -964,7 +964,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { } } put_short(s, (uint16_t)strm->adler); - FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold); + strm->adler = CRC32_INITIAL_VALUE; } s->status = BUSY_STATE; @@ -1035,8 +1035,6 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) { /* Write the trailer */ #ifdef GZIP if (s->wrap == 2) { - strm->adler = FUNCTABLE_CALL(crc32_fold_final)(&s->crc_fold); - put_uint32(s, strm->adler); put_uint32(s, (uint32_t)strm->total_in); } else diff --git a/deflate_p.h b/deflate_p.h index 81b715bc5..7b5d56019 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -152,7 +152,7 @@ Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf memcpy(buf, strm->next_in, len); #ifdef GZIP } else if (s->wrap == 2) { - FUNCTABLE_CALL(crc32_fold_copy)(&s->crc_fold, buf, strm->next_in, len); + strm->adler = FUNCTABLE_CALL(crc32_copy)(strm->adler, buf, strm->next_in, len); #endif } else if (s->wrap == 1) { strm->adler = FUNCTABLE_CALL(adler32_copy)(strm->adler, buf, strm->next_in, len); diff --git a/functable.c b/functable.c index 69b87cb3a..e33d8ef3a 100644 --- a/functable.c +++ b/functable.c @@ -82,10 +82,7 @@ static int init_functable(void) { ft.adler32 = &adler32_c; ft.adler32_copy = &adler32_copy_c; ft.crc32 = &crc32_braid; - ft.crc32_fold = &crc32_fold_c; - ft.crc32_fold_copy = &crc32_fold_copy_c; - ft.crc32_fold_final = &crc32_fold_final_c; - ft.crc32_fold_reset = &crc32_fold_reset_c; + ft.crc32_copy = &crc32_copy_braid; # ifndef HAVE_BUILTIN_CTZ ft.longest_match = &longest_match_c; ft.longest_match_slow = &longest_match_slow_c; @@ -97,10 +94,7 @@ static int init_functable(void) { ft.adler32_copy = &adler32_copy_c; ft.chunkmemset_safe = &chunkmemset_safe_c; ft.crc32 = &crc32_braid; - ft.crc32_fold = &crc32_fold_c; - ft.crc32_fold_copy = &crc32_fold_copy_c; - ft.crc32_fold_final = &crc32_fold_final_c; - ft.crc32_fold_reset = &crc32_fold_reset_c; + ft.crc32_copy = &crc32_copy_braid; ft.inflate_fast = &inflate_fast_c; ft.slide_hash = &slide_hash_c; ft.longest_match = &longest_match_c; @@ -114,6 +108,7 @@ static int init_functable(void) { // Chorba generic C fallback #ifndef WITHOUT_CHORBA ft.crc32 = &crc32_chorba; + ft.crc32_copy = &crc32_copy_chorba; #endif // X86 - SSE2 @@ -125,6 +120,7 @@ static int init_functable(void) { ft.chunkmemset_safe = &chunkmemset_safe_sse2; # if !defined(WITHOUT_CHORBA_SSE) ft.crc32 = &crc32_chorba_sse2; + ft.crc32_copy = &crc32_copy_chorba_sse2; # endif ft.inflate_fast = &inflate_fast_sse2; ft.slide_hash = &slide_hash_sse2; @@ -148,6 +144,7 @@ static int init_functable(void) { #if defined(X86_SSE41) && !defined(WITHOUT_CHORBA_SSE) if (cf.x86.has_sse41) { ft.crc32 = &crc32_chorba_sse41; + ft.crc32_copy = &crc32_copy_chorba_sse41; } #endif @@ -161,10 +158,7 @@ static int init_functable(void) { #ifdef X86_PCLMULQDQ_CRC if (cf.x86.has_pclmulqdq) { ft.crc32 = &crc32_pclmulqdq; - ft.crc32_fold = &crc32_fold_pclmulqdq; - ft.crc32_fold_copy = &crc32_fold_pclmulqdq_copy; - ft.crc32_fold_final = &crc32_fold_pclmulqdq_final; - ft.crc32_fold_reset = &crc32_fold_pclmulqdq_reset; + ft.crc32_copy = &crc32_copy_pclmulqdq; } #endif // X86 - AVX @@ -210,10 +204,7 @@ static int init_functable(void) { #ifdef X86_VPCLMULQDQ_CRC if (cf.x86.has_pclmulqdq && cf.x86.has_avx512_common && cf.x86.has_vpclmulqdq) { ft.crc32 = &crc32_vpclmulqdq; - ft.crc32_fold = &crc32_fold_vpclmulqdq; - ft.crc32_fold_copy = &crc32_fold_vpclmulqdq_copy; - ft.crc32_fold_final = &crc32_fold_vpclmulqdq_final; - ft.crc32_fold_reset = &crc32_fold_vpclmulqdq_reset; + ft.crc32_copy = &crc32_copy_vpclmulqdq; } #endif @@ -249,8 +240,7 @@ static int init_functable(void) { #ifdef ARM_CRC32 if (cf.arm.has_crc32) { ft.crc32 = &crc32_armv8; - ft.crc32_fold = &crc32_fold_armv8; - ft.crc32_fold_copy = &crc32_fold_copy_armv8; + ft.crc32_copy = &crc32_copy_armv8; } #endif @@ -272,8 +262,10 @@ static int init_functable(void) { } #endif #ifdef POWER8_VSX_CRC32 - if (cf.power.has_arch_2_07) + if (cf.power.has_arch_2_07) { ft.crc32 = &crc32_power8; + ft.crc32_copy = &crc32_copy_power8; + } #endif // Power9 #ifdef POWER9 @@ -303,21 +295,23 @@ static int init_functable(void) { #ifdef RISCV_CRC32_ZBC if (cf.riscv.has_zbc) { ft.crc32 = &crc32_riscv64_zbc; + ft.crc32_copy = &crc32_copy_riscv64_zbc; } #endif // S390 #ifdef S390_CRC32_VX - if (cf.s390.has_vx) + if (cf.s390.has_vx) { ft.crc32 = crc32_s390_vx; + ft.crc32_copy = crc32_copy_s390_vx; + } #endif // LOONGARCH #ifdef LOONGARCH_CRC if (cf.loongarch.has_crc) { ft.crc32 = crc32_loongarch64; - ft.crc32_fold = &crc32_fold_loongarch64; - ft.crc32_fold_copy = &crc32_fold_copy_loongarch64; + ft.crc32_copy = crc32_copy_loongarch64; } #endif #ifdef LOONGARCH_LSX @@ -358,10 +352,7 @@ static int init_functable(void) { FUNCTABLE_VERIFY_ASSIGN(ft, chunkmemset_safe); FUNCTABLE_VERIFY_ASSIGN(ft, compare256); FUNCTABLE_VERIFY_ASSIGN(ft, crc32); - FUNCTABLE_VERIFY_ASSIGN(ft, crc32_fold); - FUNCTABLE_VERIFY_ASSIGN(ft, crc32_fold_copy); - FUNCTABLE_VERIFY_ASSIGN(ft, crc32_fold_final); - FUNCTABLE_VERIFY_ASSIGN(ft, crc32_fold_reset); + FUNCTABLE_VERIFY_ASSIGN(ft, crc32_copy); FUNCTABLE_VERIFY_ASSIGN(ft, inflate_fast); FUNCTABLE_VERIFY_ASSIGN(ft, longest_match); FUNCTABLE_VERIFY_ASSIGN(ft, longest_match_slow); @@ -403,24 +394,9 @@ static uint32_t crc32_stub(uint32_t crc, const uint8_t* buf, size_t len) { return functable.crc32(crc, buf, len); } -static void crc32_fold_stub(crc32_fold* crc, const uint8_t* src, size_t len, uint32_t init_crc) { - FUNCTABLE_INIT_ABORT; - functable.crc32_fold(crc, src, len, init_crc); -} - -static void crc32_fold_copy_stub(crc32_fold* crc, uint8_t* dst, const uint8_t* src, size_t len) { - FUNCTABLE_INIT_ABORT; - functable.crc32_fold_copy(crc, dst, src, len); -} - -static uint32_t crc32_fold_final_stub(crc32_fold* crc) { - FUNCTABLE_INIT_ABORT; - return functable.crc32_fold_final(crc); -} - -static uint32_t crc32_fold_reset_stub(crc32_fold* crc) { +static uint32_t crc32_copy_stub(uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len) { FUNCTABLE_INIT_ABORT; - return functable.crc32_fold_reset(crc); + return functable.crc32_copy(crc, dst, src, len); } static void inflate_fast_stub(PREFIX3(stream) *strm, uint32_t start) { @@ -451,10 +427,7 @@ Z_INTERNAL struct functable_s functable = { chunkmemset_safe_stub, compare256_stub, crc32_stub, - crc32_fold_stub, - crc32_fold_copy_stub, - crc32_fold_final_stub, - crc32_fold_reset_stub, + crc32_copy_stub, inflate_fast_stub, longest_match_stub, longest_match_slow_stub, diff --git a/functable.h b/functable.h index 044cf8ac7..0fa2e9724 100644 --- a/functable.h +++ b/functable.h @@ -30,10 +30,7 @@ struct functable_s { uint8_t* (* chunkmemset_safe) (uint8_t *out, uint8_t *from, unsigned len, unsigned left); uint32_t (* compare256) (const uint8_t *src0, const uint8_t *src1); uint32_t (* crc32) (uint32_t crc, const uint8_t *buf, size_t len); - void (* crc32_fold) (struct crc32_fold_s *crc, const uint8_t *src, size_t len, uint32_t init_crc); - void (* crc32_fold_copy) (struct crc32_fold_s *crc, uint8_t *dst, const uint8_t *src, size_t len); - uint32_t (* crc32_fold_final) (struct crc32_fold_s *crc); - uint32_t (* crc32_fold_reset) (struct crc32_fold_s *crc); + uint32_t (* crc32_copy) (uint32_t crc, uint8_t *dst, const uint8_t *src, size_t len); void (* inflate_fast) (PREFIX3(stream) *strm, uint32_t start); uint32_t (* longest_match) (deflate_state *const s, uint32_t cur_match); uint32_t (* longest_match_slow) (deflate_state *const s, uint32_t cur_match); diff --git a/inflate.c b/inflate.c index 4cac4817d..2339804f8 100644 --- a/inflate.c +++ b/inflate.c @@ -28,7 +28,7 @@ static inline void inf_chksum_cpy(PREFIX3(stream) *strm, uint8_t *dst, struct inflate_state *state = (struct inflate_state*)strm->state; #ifdef GUNZIP if (state->flags) { - FUNCTABLE_CALL(crc32_fold_copy)(&state->crc_fold, dst, src, copy); + strm->adler = state->check = FUNCTABLE_CALL(crc32_copy)(state->check, dst, src, copy); } else #endif { @@ -40,7 +40,7 @@ static inline void inf_chksum(PREFIX3(stream) *strm, const uint8_t *src, uint32_ struct inflate_state *state = (struct inflate_state*)strm->state; #ifdef GUNZIP if (state->flags) { - FUNCTABLE_CALL(crc32_fold)(&state->crc_fold, src, len, 0); + strm->adler = state->check = FUNCTABLE_CALL(crc32)(state->check, src, len); } else #endif { @@ -697,7 +697,7 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { } /* compute crc32 checksum if not in raw mode */ if ((state->wrap & 4) && state->flags) - strm->adler = state->check = FUNCTABLE_CALL(crc32_fold_reset)(&state->crc_fold); + strm->adler = state->check = CRC32_INITIAL_VALUE; state->mode = TYPE; break; #endif @@ -1117,10 +1117,6 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) { if (out) { inf_chksum(strm, put - out, out); } -#ifdef GUNZIP - if (state->flags) - strm->adler = state->check = FUNCTABLE_CALL(crc32_fold_final)(&state->crc_fold); -#endif } out = left; if ((state->wrap & 4) && ( diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2ce549e8d..bbaf1035c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -180,7 +180,7 @@ if(WITH_GTEST) test_compare256.cc # compare256_neon(), etc test_compare256_rle.cc # compare256_rle(), etc test_crc32.cc # crc32_armv8(), etc - test_crc32_fold_copy.cc # crc32_fold_copy implementations + test_crc32_copy.cc # crc32_copy implementations test_inflate_sync.cc # expects a certain compressed block layout test_main.cc # cpu_check_features() test_version.cc # expects a fixed version string diff --git a/test/benchmarks/CMakeLists.txt b/test/benchmarks/CMakeLists.txt index 79f49b1fa..c9fe520ad 100644 --- a/test/benchmarks/CMakeLists.txt +++ b/test/benchmarks/CMakeLists.txt @@ -44,7 +44,7 @@ add_executable(benchmark_zlib benchmark_compare256_rle.cc benchmark_compress.cc benchmark_crc32.cc - benchmark_crc32_fold_copy.cc + benchmark_crc32_copy.cc benchmark_insert_string.cc benchmark_main.cc benchmark_slidehash.cc diff --git a/test/benchmarks/benchmark_crc32_fold_copy.cc b/test/benchmarks/benchmark_crc32_copy.cc similarity index 100% rename from test/benchmarks/benchmark_crc32_fold_copy.cc rename to test/benchmarks/benchmark_crc32_copy.cc diff --git a/test/test_crc32.cc b/test/test_crc32.cc index a49c9d72b..2a0da7eb9 100644 --- a/test/test_crc32.cc +++ b/test/test_crc32.cc @@ -140,7 +140,7 @@ TEST_CRC32(vpclmulqdq, crc32_vpclmulqdq, (test_cpu_features.x86.has_pclmulqdq && TEST_CRC32(chorba_sse41, crc32_chorba_sse41, test_cpu_features.x86.has_sse41) # endif #endif -#if defined(LOONGARCH_CRC) +#ifdef LOONGARCH_CRC INSTANTIATE_TEST_SUITE_P(crc32_alignment, crc32_align, testing::ValuesIn(align_offsets)); TEST_CRC32(loongarch64, crc32_loongarch64, test_cpu_features.loongarch.has_crc) TEST_CRC32_ALIGN(loongarch64_align, crc32_loongarch64, test_cpu_features.loongarch.has_crc) diff --git a/test/test_crc32_fold_copy.cc b/test/test_crc32_copy.cc similarity index 100% rename from test/test_crc32_fold_copy.cc rename to test/test_crc32_copy.cc