diff options
| author | Nathan Moinvaziri <nathan@nathanm.com> | 2021-12-31 08:22:35 -0800 |
|---|---|---|
| committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2022-01-08 13:56:43 +0100 |
| commit | 18f6c95d504f643b69b63d86cff5efe669143cac (patch) | |
| tree | 296f996ec59646d1756186a67719088d5253c39a | |
| parent | a5cc4257c9de2c6b50b4238b9008e0fe4d11422c (diff) | |
| download | Project-Tick-18f6c95d504f643b69b63d86cff5efe669143cac.tar.gz Project-Tick-18f6c95d504f643b69b63d86cff5efe669143cac.zip | |
Move generic crc32 assignment to else statement so it can be optimized away if use_byfour is true.
| -rw-r--r-- | functable.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/functable.c b/functable.c index c2e23f55e7..0118dc5b74 100644 --- a/functable.c +++ b/functable.c @@ -523,31 +523,28 @@ Z_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64_t Assert(sizeof(uint64_t) >= sizeof(size_t), "crc32_z takes size_t but internally we have a uint64_t len"); - /* return a function pointer for optimized arches here after a capability test */ - - functable.crc32 = &crc32_generic; - cpu_check_features(); if (use_byfour) { #if BYTE_ORDER == LITTLE_ENDIAN functable.crc32 = crc32_little; -# if defined(ARM_ACLE_CRC_HASH) - if (arm_cpu_has_crc32) - functable.crc32 = crc32_acle; -# endif #elif BYTE_ORDER == BIG_ENDIAN functable.crc32 = crc32_big; -# if defined(S390_CRC32_VX) - if (s390_cpu_has_vx) - functable.crc32 = s390_crc32_vx; -# endif #else # error No endian defined #endif + } else { + functable.crc32 = &crc32_generic; } -#if defined(POWER8_VSX_CRC32) + cpu_check_features(); +#ifdef ARM_ACLE_CRC_HASH + if (arm_cpu_has_crc32) + functable.crc32 = crc32_acle; +#elif defined(POWER8_VSX_CRC32) if (power_cpu_has_arch_2_07) functable.crc32 = crc32_power8; +#elif defined(S390_CRC32_VX) + if (s390_cpu_has_vx) + functable.crc32 = s390_crc32_vx; #endif return functable.crc32(crc, buf, len); |
