I want to find the fastest way to get the index of the lowest order bit of a long long. ie:
00101001001000 -> 3
Solutions involving looping and shifting are too slow. ie:
int i;
if(bits == 0ULL) {
i = 64;
} else {
for(i = 0;!(bits & 1ULL);i++)
bits >>= 1;
}
EDIT: Info on usage
The function that uses ffsll can't really reduce its usage, but here it is (simplified of course). It just iterates through the indices and does something with them. This function is perhaps the most widely used function in my whole application despite a lot of caching of its value. It's a legal move generator in my alpha-beta search engine.
while(bits){
index = ffsll(bits);
doSomething(index);
index &= index-1;
}