Skip to content

Add portable SIMD swizzle, multishift, compress, and expand - #349

Open
Novum wants to merge 1 commit into
linebender:mainfrom
Novum:fearless-simd-swizzle-multishift-compress-expand
Open

Add portable SIMD swizzle, multishift, compress, and expand#349
Novum wants to merge 1 commit into
linebender:mainfrom
Novum:fearless-simd-swizzle-multishift-compress-expand

Conversation

@Novum

@Novum Novum commented Aug 25, 2026

Copy link
Copy Markdown

I needed those ops in a project of mine so I gave it a go.

This adds 128-, 256-, and 512-bit operations for concatenated dynamic swizzles, per-64-bit-lane multishift, masked compression/expansion, and masked expand-loads.

Concatenated swizzles use optimized existing primitives on SSE4.2, AVX2, Neon, and Wasm, while AVX-512 uses native VBMI/VBMI2 instructions.

As usual there are scalar fallbacks for portable code.

^ Conflicts:
^	CHANGELOG.md
^	fearless_simd_gen/src/mk_neon.rs
^	fearless_simd_gen/src/mk_wasm.rs
^	fearless_simd_gen/src/mk_x86.rs
@Novum
Novum force-pushed the fearless-simd-swizzle-multishift-compress-expand branch from 0978b34 to 903da47 Compare August 25, 2026 08:00
@Shnatsel

Copy link
Copy Markdown
Contributor

Thanks for the PR!

I really don't want to add ops that only exist on AVX-512 as "portable" ops. The proper way to deal with these is to write a kernel! for AVX-512 and route everything else to a fallback in user code, like this: https://github.com/linebender/fearless_simd/blob/main/fearless_simd/examples/srgb.rs

I can see us adding concat_swizzle_dyn along with the _precise variant because that can have meaningfully different lowerings than simply calling swizzle_dyn_precise and joining the halves, which a user could already do. NEON can directly use wider tbl for 128 and 256-bit vectors and has a reasonable lowering for 512-bit vectors by OR-ing two 512-bit swizzle_dyn_precise.

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