From bbd764467732aed6993feb74e070c0afa63b9520 Mon Sep 17 00:00:00 2001 From: Frank Tetzel Date: Thu, 28 Sep 2017 19:18:05 +0200 Subject: [PATCH] use BMI2's bzhi for rank calculation It is not really faster. It only gets rid of the static lookup table. --- include/sdsl/rank_support.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/sdsl/rank_support.hpp b/include/sdsl/rank_support.hpp index 2137f882a..c856d675d 100644 --- a/include/sdsl/rank_support.hpp +++ b/include/sdsl/rank_support.hpp @@ -147,7 +147,13 @@ struct rank_support_trait<1,1> { static uint32_t word_rank(const uint64_t* data, size_type idx) { - return bits::cnt(*(data+(idx>>6)) & bits::lo_set[idx&0x3F]); +#ifdef __BMI2__ + return bits::cnt( + _bzhi_u64(data[idx>>6], idx&0x3F) + ); +#else + return bits::cnt(*(data+(idx>>6)) & bits::lo_set[idx&0x3F]); +#endif } static uint32_t full_word_rank(const uint64_t* data, size_type idx)