ZLIB_INTERNAL int x86_cpu_has_sse2;
ZLIB_INTERNAL int x86_cpu_has_sse42;
ZLIB_INTERNAL int x86_cpu_has_pclmulqdq;
+ZLIB_INTERNAL int x86_cpu_has_tzcnt;
static void cpuid(int info, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx) {
#ifdef _MSC_VER
x86_cpu_has_sse2 = edx & 0x4000000;
x86_cpu_has_sse42 = ecx & 0x100000;
x86_cpu_has_pclmulqdq = ecx & 0x2;
+
+ cpuid(7, &eax, &ebx, &ecx, &edx);
+
+ x86_cpu_has_tzcnt = ecx & 0x8;
}
extern int x86_cpu_has_sse2;
extern int x86_cpu_has_sse42;
extern int x86_cpu_has_pclmulqdq;
+extern int x86_cpu_has_tzcnt;
void ZLIB_INTERNAL x86_check_features(void);
;;
esac
- CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNROLL_LESS -DX86_CPUID"
- SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNROLL_LESS -DX86_CPUID"
+ CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNROLL_LESS"
+ SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNROLL_LESS"
# Enable arch-specific optimizations?
if test $without_optimizations -eq 0; then
+ CFLAGS="${CFLAGS} -DX86_CPUID"
+ SFLAGS="${SFLAGS} -DX86_CPUID"
+
ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} x86.o"
ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} x86.lo"
* output size for (length,distance) codes is <= 24 bits.
*/
-#if defined(X86_SSE2_FILL_WINDOW) || defined(X86_SSE4_2_CRC_HASH)
+#ifdef X86_CPUID
x86_check_features();
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h>
-/* This is not a general purpose replacement for __builtin_ctzl. The function expects that value is != 0
- * Because of that assumption trailing_zero is not initialized and the return value of _BitScanForward is not checked
- */
-static __forceinline unsigned long __builtin_ctzl(unsigned long value)
-{
- unsigned long trailing_zero;
- _BitScanForward(&trailing_zero, value);
- return trailing_zero;
-}
+# ifdef X86_CPUID
+# include "arch/x86/x86.h"
+# endif
#endif
#endif
#ifdef std3_longest_match
+
+#if defined(_MSC_VER) && !defined(__clang__)
+/* This is not a general purpose replacement for __builtin_ctzl. The function expects that value is != 0
+ * Because of that assumption trailing_zero is not initialized and the return value of _BitScanForward is not checked
+ */
+static __forceinline unsigned long __builtin_ctzl(unsigned long value)
+{
+#ifdef X86_CPUID
+ if (x86_cpu_has_tzcnt)
+ return _tzcnt_u32(value);
+#endif
+ unsigned long trailing_zero;
+ _BitScanForward(&trailing_zero, value);
+ return trailing_zero;
+}
+#endif
+
/* longest_match() with minor change to improve performance (in terms of
* execution time).
*