[PATCH] D28817: Add SparseBitVector::find_last()

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 11:35:29 PST 2017


zturner added inline comments.


================
Comment at: llvm/include/llvm/ADT/SparseBitVector.h:141
+        return Idx * BITWORD_SIZE + BITWORD_SIZE -
+               countLeadingZeros(Bits[Idx]) - 1;
+    }
----------------
dberlin wrote:
> Don't you really just want counttrailingzeros, and the index is bitword_size - count trailing zeros?
> 
I made the same mistake at first.  Because the LSB is the bit with the lowest "index", we have to use `countLeadingZeros`.  i.e. 0b00000000000000000000000000000110  has bits 1 and 2 set.  The value we want returned from the function is 2.


Repository:
  rL LLVM

https://reviews.llvm.org/D28817





More information about the llvm-commits mailing list