Make bitset `would_modify_words` more vectorizer-friendly
Currently this function compares a single pair of `u64` at a time, which is potentially slower than comparing multiple words before each early-exit check, especially for the large chunks used by ChunkedBitSet.
Perf shows a notable improvement in `cranelift-codegen`, which is the one benchmark that is known to stress these code paths.
- Incorporates https://github.com/rust-lang/rust/pull/153759.
Add a suite of ChunkedBitSet union/subtract/intersect test scenarios
While working on https://github.com/rust-lang/rust/pull/153754, I found that these code paths are under-tested.
Fix a bug in `ChunkedBitSet::subtract`
An operator precedence bug means an incorrect mask is used in `ChunkedBitSet::subtract`. Details in individual commits.
r? @dingxiangfei2009
It does a masking operation but the mask is computed incorrectly due to
operator precedence. The mask is of the form `1 << N - 1` but it
should be `(1 << N) - 1` because `-` binds tighter than `1 << N`.
This commit fixes the problem, not by adjusting the precedence, but by
instead using the existing `clear_excess_bits_in_final_word`, which is
consistent with other similar operations.
LLM disclosure: this bug was identified by Claude Code. I did everything
else.
stabilizes `core::range::Range`
stabilizes `core::range::RangeIter`
stabilizes `std::range` which was missed in prior PRs
Updates docs to reflect stabilization (removed "experimental")
`RangeIter::remainder` is excluded from stabilization
Add functions to `GrowableBitSet`
Only really need `insert_range` for clippy, but may as well add the others. Using `Range` instead of `RangeBounds` since an end bound is needed for this to make sense and there aren't any traits to enforce that.
Now that Rc::new_zeroed is stable, remove the cfg(feature = "nightly")
branch and the temporary zeroed array on stable. This avoids copying a
potentially large [Word; CHUNK_WORDS] into the Rc.
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
All usages of `memory_index` start by calling `invert_bijective_mapping`, so
storing the inverted mapping directly saves some work and simplifies the code.
Use `bit_set::Word` in a couple more places.
It's a synonym for `u64` and there are a couple of places where we use `u64` where we should use `Word`, which this commit fixes.
I found this when I tried changing `Word` to `u128` (which made performance worse).
r? `````@Zalathar`````
It's a synonym for `u64` and there are a couple of places where we use
`u64` where we should use `Word`, which this commit fixes.
I found this when I tried changing `Word` to `u128` (which made
performance worse).
Stabilize `new_zeroed_alloc`
The corresponding `new_uninit` and `new_uninit_slice` functions were stabilized in rust-lang/rust#129401, but the zeroed counterparts were left for later out of a [desire](https://github.com/rust-lang/rust/issues/63291#issuecomment-2161039756) to stabilize only the minimal set. These functions are straightforward mirrors of the uninit functions and well-established. Since no blockers or design questions have surfaced in the past year, I think it's time to stabilize them.
Tracking issue: rust-lang/rust#129396