swizzle_dyn: 64 byte swizzle_dyn for AVX2 - #480
Conversation
3bdb528 to
c045fbe
Compare
| use x86::_mm256_permute2x128_si256 as avx2_cross_shuffle; | ||
| use x86::_mm256_shuffle_epi8 as avx2_half_pshufb; | ||
| let high = Simd::splat(64u8); | ||
| // SAFETY: Caller promised AVX2 |
There was a problem hiding this comment.
you should probably add more safety comments, e.g. answer why is the transmute sound?
There was a problem hiding this comment.
Added one for the transmute. Can't really think of anywhere else where its required.
|
The |
|
@jhorstmann Agreed. |
| let z0 = half_swizzler(bytes0, bytes1, idxs0); | ||
| let z1 = half_swizzler(bytes0, bytes1, idxs1); | ||
|
|
||
| // SAFETY: Concatenation of two 32-element vectors to one 64-element vector |
There was a problem hiding this comment.
this says what your doing, what it should say is why it's safe to use transmute like this. e.g.:
[Simd<u8, 32>; 2] and Simd<u8, 64> both have the same size (64) and no padding bytes, so transmuting is safe
|
☔ The latest upstream changes (possibly #533) made this pull request unmergeable. Please resolve the merge conflicts. |
|
FWIW #540 applied a similar operation generically, for all cases where swizzle_dyn operates on double the native vector width. |
Implemented a 64 bit
swizzle_dynfor AVX2.Use case: Encountered this while implementing a chess move generator in rust with portable simd.
Would like an alternative suggestion for use of
mem::transmutehere.