[llvm] [ADT] Refactor Bitset to Be More Constexpr-Usable and Add More Member Functions (PR #172062)
Jiachen Yuan via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 15 13:12:07 PST 2025
================
@@ -96,14 +109,28 @@ class Bitset {
constexpr size_t size() const { return NumBits; }
- bool any() const {
- return llvm::any_of(Bits, [](BitWord I) { return I != 0; });
+ constexpr bool any() const {
+ for (unsigned I = 0; I < NumWords - 1; ++I)
----------------
JiachenYuan wrote:
Previously, the last word needed some special masking due to the messy situation when the size of the `Bitset` is not a multiple of the `BitwordBits`. However, as I refactored to maintain the "Remainder bits are always 0" invariant, the speical handling of the last word in these functions is not needed anymore. So, in short, there is no -1 anymore.
The summary of the latest commit: https://github.com/llvm/llvm-project/pull/172062#issuecomment-3657243363
https://github.com/llvm/llvm-project/pull/172062
More information about the llvm-commits
mailing list