From 19f2c46d1b7ecada7f6f8555eda6288a311b6722 Mon Sep 17 00:00:00 2001 From: Konstantine Kharlamov Date: Wed, 23 May 2018 12:46:25 +0300 Subject: [PATCH] igzip: fix build failure for CPUs with BMI capability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …also makes use of an optimized algorithm for x86_64 CPUs without the BMI. v2: use "defined()" macro igzip: s/__bsfq/__builtin_ctzll Per discussion at https://github.com/01org/isa-l/pull/38 __bsfq isn't defined on clang, but __builtin_ctzll should work same way. Also, refactor the code a bit. Change-Id: I1a251abe1fab1be1cbdc2c042298d0b500068c68 Signed-off-by: Konstantin Kharlamov --- igzip/huffman.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/igzip/huffman.h b/igzip/huffman.h index e74f2f7..922a3a6 100644 --- a/igzip/huffman.h +++ b/igzip/huffman.h @@ -62,11 +62,9 @@ static inline uint32_t tzcnt(uint64_t val) #ifdef __BMI__ cnt = __tzcnt_u64(val); cnt = cnt / 8; -#elifdef __x86_64__ +#elif defined(__x86_64__) - cnt = __bsfq(val); - if(val == 0) - cnt = 64; + cnt = (val == 0)? 64 : __builtin_ctzll(val); cnt = cnt / 8; #else