Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use BMI2's bzhi for rank calculation #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/sdsl/rank_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down