]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Move generic crc32 assignment to else statement so it can be optimized away if use_by...
authorNathan Moinvaziri <nathan@nathanm.com>
Fri, 31 Dec 2021 16:22:35 +0000 (08:22 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 8 Jan 2022 12:56:43 +0000 (13:56 +0100)
functable.c

index c2e23f55e724ab2596154a9aeeafb15e5dc49bb0..0118dc5b7406a1774fd9e46e9a58f90c6e69f6ee 100644 (file)
@@ -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);