[llvm] [ADT] Define countr_zero in terms of popcount (NFC) (PR #158519)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 14 18:54:05 PDT 2025


================
@@ -148,6 +148,35 @@ template <typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>>
   return (Value != 0) && ((Value & (Value - 1)) == 0);
 }
 
+/// Count the number of set bits in a value.
+/// Ex. popcount(0xF000F000) = 8
+/// Returns 0 if the word is zero.
----------------
kuhar wrote:

```suggestion
/// Returns 0 if Value is zero.
```
?

https://github.com/llvm/llvm-project/pull/158519


More information about the llvm-commits mailing list