diff options
| author | Ralf Jung <post@ralfj.de> | 2024-09-12 11:33:13 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-09-14 14:43:24 +0200 |
| commit | 4111fb2cbd63e98a85436aa163d0f9a2dac5ee3e (patch) | |
| tree | b889bb3dc14c35f43e82f6630cddf34878d0973e | |
| parent | 048ba3e4b16f97707bacf2baed89e90dc9d6974e (diff) | |
| download | rust-4111fb2cbd63e98a85436aa163d0f9a2dac5ee3e.tar.gz rust-4111fb2cbd63e98a85436aa163d0f9a2dac5ee3e.zip | |
simd_shuffle: require index argument to be a vector
| -rw-r--r-- | crates/core_simd/src/swizzle.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/core_simd/src/swizzle.rs b/crates/core_simd/src/swizzle.rs index 2f4f777b20e..d62642fb906 100644 --- a/crates/core_simd/src/swizzle.rs +++ b/crates/core_simd/src/swizzle.rs @@ -85,7 +85,7 @@ pub trait Swizzle<const N: usize> { LaneCount<N>: SupportedLaneCount, LaneCount<M>: SupportedLaneCount, { - // Safety: `vector` is a vector, and the index is a const array of u32. + // Safety: `vector` is a vector, and the index is a const vector of u32. unsafe { core::intrinsics::simd::simd_shuffle( vector, @@ -103,7 +103,11 @@ pub trait Swizzle<const N: usize> { output[i] = index as u32; i += 1; } - output + + // The index list needs to be returned as a vector. + #[repr(simd)] + struct SimdShuffleIdx<const LEN: usize>([u32; LEN]); + SimdShuffleIdx(output) }, ) } @@ -121,7 +125,7 @@ pub trait Swizzle<const N: usize> { LaneCount<N>: SupportedLaneCount, LaneCount<M>: SupportedLaneCount, { - // Safety: `first` and `second` are vectors, and the index is a const array of u32. + // Safety: `first` and `second` are vectors, and the index is a const vector of u32. unsafe { core::intrinsics::simd::simd_shuffle( first, @@ -139,7 +143,11 @@ pub trait Swizzle<const N: usize> { output[i] = index as u32; i += 1; } - output + + // The index list needs to be returned as a vector. + #[repr(simd)] + struct SimdShuffleIdx<const LEN: usize>([u32; LEN]); + SimdShuffleIdx(output) }, ) } |
