Skip to content

Use PCMPISTRM for the intersection and difference comparison on SSE4.2+ in Stable Simd - #380

Open
Dr-Emann wants to merge 1 commit into
stable_simdfrom
stable_simd_pcmpistrm
Open

Dr-Emann wants to merge 1 commit into
stable_simdfrom
stable_simd_pcmpistrm

Conversation

@Dr-Emann

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

Copy link
Copy Markdown
Member

Look ma, no unsafe!

Following CRoaring, compare a vector of lhs against a vector of rhs with the SSE4.2 PCMPISTRM instruction via a fearless_simd::kernel!. PCMPISTRM treats a zero lane as the end of the string, so the slower PCMPESTRM is used while either current vector may start with a zero (only possible at the start of the sorted arrays). Other SIMD levels keep the portable all-pairs comparison.

Compared with the portable comparison, and, and_len and sub are 4-13% faster with default flags and 3-21% faster with -C target-cpu=native. Using PCMPESTRM throughout was 0-12% slower.

@Dr-Emann
Dr-Emann added this pull request to stack #381 October 9, 2026 17:16
@Dr-Emann
Dr-Emann force-pushed the stable_simd_pcmpistrm branch from ea864db to 3efbae2 Compare October 9, 2026 17:22
@Dr-Emann
Dr-Emann force-pushed the stable_simd_pcmpistrm branch from 3efbae2 to b21d9fd Compare October 9, 2026 19:05
@Dr-Emann
Dr-Emann force-pushed the stable_simd_pcmpistrm branch from b21d9fd to 9c10d41 Compare October 9, 2026 19:20
Following CRoaring, compare a vector of `lhs` against a vector of `rhs`
with the SSE4.2 PCMPISTRM instruction via a `fearless_simd::kernel!`.
PCMPISTRM treats a zero lane as the end of the string, so the slower
PCMPESTRM is used while either current vector may start with a zero (only
possible at the start of the sorted arrays). Other SIMD levels keep the
portable all-pairs comparison.

Compared with the portable comparison, `and`, `and_len` and `sub` are
4-13% faster with default flags and 3-21% faster with
`-C target-cpu=native`. Using PCMPESTRM throughout was 0-12% slower.
@Dr-Emann
Dr-Emann force-pushed the stable_simd_pcmpistrm branch from 9c10d41 to 51fde93 Compare October 9, 2026 19:56
@emschwartz emschwartz mentioned this pull request Oct 10, 2026

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