Skip to content

refactor: select merge input with select_unpredictable, as_chunks in Stable Simd - #383

Open
Dr-Emann wants to merge 1 commit into
stable_simd_bitonic_sortfrom
stable_simd_refactor
Open

Dr-Emann wants to merge 1 commit into
stable_simd_bitonic_sortfrom
stable_simd_refactor

Conversation

@Dr-Emann

@Dr-Emann Dr-Emann commented Oct 9, 2026

Copy link
Copy Markdown
Member

Collapse the branchy loop/break merge in the array-store SIMD union and xor into a single while loop. It picks the next input vector with core::hint::select_unpredictable, which hints the compiler to select without branching, because which side advances is essentially unpredictable. This ports the equivalent change from CRoaring.

Split the inputs with as_chunks::<LANES>() and load whole chunks with load_array_ref instead of indexing slices by 8 * i. A slice pattern on the chunk lists handles the scalar fallback. select_unpredictable now picks the chunk and the index to advance together.

This has a nice benefit of removing a fair number of bounds checks

@Dr-Emann
Dr-Emann added this pull request to stack #381 October 9, 2026 19:59
@Dr-Emann Dr-Emann changed the title refactor: select merge input with select_unpredictable, as_chunks refactor: select merge input with select_unpredictable, as_chunks in Stable Simd Oct 9, 2026
@emschwartz emschwartz mentioned this pull request Oct 10, 2026
Collapse the branchy loop/break merge in the array-store SIMD union and
xor into a single while loop. It picks the next input vector with
core::hint::select_unpredictable, which hints the compiler to select
without branching, because which side advances is essentially
unpredictable. This ports the equivalent change from CRoaring.

Split the inputs with `as_chunks::<LANES>()` and load whole chunks with
`load_array_ref` instead of indexing slices by `8 * i`. A slice pattern
on the chunk lists handles the scalar fallback. `select_unpredictable`
now picks the chunk and the index to advance together.

This has a nice benefit of removing a fair number of bounds checks
@Dr-Emann
Dr-Emann force-pushed the stable_simd_refactor branch from fec473a to d626bbb Compare October 11, 2026 02:53

This branch has not been deployed

No deployments
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.

1 participant