Skip to content

Feat/u64 bit ops - #15

Merged
jcfangc merged 7 commits into
mainfrom
feat/u64-bit-ops
Jun 27, 2026
Merged

Feat/u64 bit ops#15
jcfangc merged 7 commits into
mainfrom
feat/u64-bit-ops

Conversation

@jcfangc

@jcfangc jcfangc commented Jun 27, 2026

Copy link
Copy Markdown
Owner

No description provided.

jcfangc and others added 7 commits June 27, 2026 03:45
BitStr::leading_zeros() counts consecutive false bits from the start of a
view. Internally delegates to BitsArith::leading_zero_words() on [u64],
which uses SIMD (AVX2/SSE2/NEON) to skip over zero words in batches of
4 or 2, falling back to scalar for short inputs.

Backend equivalence tests validate all SIMD paths against the scalar
oracle.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: DeepSeek AI <service@deepseek.com>
- BitStr::leading_zeros() and leading_ones() share a parameterised
  internal helper (leading_value_count) that dispatches fill=0 or !0

- BitsArith gains leading_one_words() alongside leading_zero_words()
  Both delegate to leading_value_words(words, fill) which uses
  AVX2/SSE4.1/NEON backends with a scalar fallback

- Rename funcs_for_leading_zero_words → funcs_for_leading_value_words
  Module parameterised by fill value, zero and one tests unified

- Fix _mm_cmpeq_epi64 requires SSE4.1, not SSE2
  Rename sse2→sse41 in 8 module files that use the intrinsic:
  leading_value_words, eq_words_aligned, eq_words_unaligned,
  contains, find, rfind, cmp_aligned, cmp_unaligned

- CI: linux-x64-ssse3 → linux-x64-sse4.1 so SSE4.1 backend
  equivalence tests are covered

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: DeepSeek AI <service@deepseek.com>
… BitStr

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: DeepSeek AI <service@deepseek.com>
Move the two delegation methods from impls_for_count_ones.rs into a new
impls_for_leading_zeros.rs — mirroring the BitStr side. No separate
tests needed; coverage is on the BitStr implementation.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: DeepSeek AI <service@deepseek.com>
BitString methods that delegate one-to-one to BitStr (matches_at,
starts_with, ends_with, contains, find, rfind, strip_prefix,
strip_suffix, cmp) no longer carry separate test modules. The logic
is already exercised by the BitStr test suite.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: DeepSeek AI <service@deepseek.com>
- BitStr::trailing_zeros() / trailing_ones() count consecutive bits
  from the end of a view — mirroring leading_* but scanning from the
  last bit backwards (uses u64::leading_zeros for within-word scan)

- BitsArith::trailing_zero_words() / trailing_one_words() with
  trailing_value_words(words, fill) dispatch — AVX2/SSE4.1/NEON
  backends process chunks in reverse order

- BitString delegates to BitStr

- 27 unit tests + 2 AVX2 backend equivalence tests for trailing scan

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: DeepSeek AI <service@deepseek.com>
Three-step word-level algorithm:
1. Reverse bits within each u64 word via u64::reverse_bits()
2. Reverse word order
3. Right-shift by unused bits to align to LSB

reverse_bits_assign() delegates to reverse_bits() via reassignment.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: DeepSeek AI <service@deepseek.com>
@codecov-commenter

Copy link
Copy Markdown

@jcfangc
jcfangc merged commit cd6871e into main Jun 27, 2026
5 of 6 checks passed
@jcfangc
jcfangc deleted the feat/u64-bit-ops branch June 27, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants