Replace CountOneBits and __builtin_popcount with POPCOUNT.
Clean up utils.h, make some functions constexpr.
Change-Id: I2399100280cbce81c3c4f5765f0680c1ddcb5883
diff --git a/runtime/base/bit_vector.cc b/runtime/base/bit_vector.cc
index 12c0352..3df5101 100644
--- a/runtime/base/bit_vector.cc
+++ b/runtime/base/bit_vector.cc
@@ -201,7 +201,7 @@
uint32_t BitVector::NumSetBits() const {
uint32_t count = 0;
for (uint32_t word = 0; word < storage_size_; word++) {
- count += __builtin_popcount(storage_[word]);
+ count += POPCOUNT(storage_[word]);
}
return count;
}
@@ -331,10 +331,10 @@
uint32_t count = 0u;
for (uint32_t word = 0u; word < word_end; word++) {
- count += __builtin_popcount(storage[word]);
+ count += POPCOUNT(storage[word]);
}
if (partial_word_bits != 0u) {
- count += __builtin_popcount(storage[word_end] & ~(0xffffffffu << partial_word_bits));
+ count += POPCOUNT(storage[word_end] & ~(0xffffffffu << partial_word_bits));
}
return count;
}