From 43483b3ddef03236029cd3baa6923cd91b09cf81 Mon Sep 17 00:00:00 2001 From: Valentin Antonescu Date: Tue, 14 Jan 2014 16:11:33 -0500 Subject: [PATCH] Dropped the intrinsics dependency and replaced popcnt with plain asm code. Also POPCNT_CAPABILITY is not by default On. --- Makefile | 4 ++-- ebwt.h | 4 +++- processor_support.h | 3 --- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 78b9be3..41fe19a 100644 --- a/Makefile +++ b/Makefile @@ -67,9 +67,9 @@ else PTHREAD_LIB = -lpthread endif -POPCNT_CAPABILITY ?= 0 +POPCNT_CAPABILITY ?= 1 ifeq (1, $(POPCNT_CAPABILITY)) - EXTRA_FLAGS += -DPOPCNT_CAPABILITY -msse4.2 + EXTRA_FLAGS += -DPOPCNT_CAPABILITY ifeq (1,$(MACOS)) INC += -I third_party/macos endif diff --git a/ebwt.h b/ebwt.h index b4f3d07..4b43fd3 100644 --- a/ebwt.h +++ b/ebwt.h @@ -1905,7 +1905,9 @@ inline static int pop64(uint64_t x) { #ifdef POPCNT_CAPABILITY struct USE_POPCNT_INSTRUCTION { inline static int pop64(uint64_t x) { - return _mm_popcnt_u64(x); + int64_t count; + asm ("popcntq %[x],%[count]\n": [count] "=&r" (count): [x] "r" (x)); + return count; } }; #endif diff --git a/processor_support.h b/processor_support.h index 0851a23..f68ee65 100644 --- a/processor_support.h +++ b/processor_support.h @@ -12,15 +12,12 @@ #if defined(__INTEL_COMPILER) # define USING_INTEL_COMPILER -# include #elif defined(__GNUC__) # define USING_GCC_COMPILER -# include # include #elif defined(_MSC_VER) // __MSC_VER defined by Microsoft compiler #define USING MSC_COMPILER -# include #endif struct regs_t {unsigned int EAX, EBX, ECX, EDX;};