igzip: fix build failure for CPUs with BMI capability

…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 <Hi-Angel@yandex.ru>
This commit is contained in:
Konstantine Kharlamov 2018-05-23 12:46:25 +03:00 committed by Greg Tucker
parent 951ec3198f
commit 19f2c46d1b

View File

@ -62,11 +62,9 @@ static inline uint32_t tzcnt(uint64_t val)
#ifdef __BMI__ #ifdef __BMI__
cnt = __tzcnt_u64(val); cnt = __tzcnt_u64(val);
cnt = cnt / 8; cnt = cnt / 8;
#elifdef __x86_64__ #elif defined(__x86_64__)
cnt = __bsfq(val); cnt = (val == 0)? 64 : __builtin_ctzll(val);
if(val == 0)
cnt = 64;
cnt = cnt / 8; cnt = cnt / 8;
#else #else