diff options
| author | Markus Everling <markuseverling@gmail.com> | 2023-05-07 00:11:56 +0000 |
|---|---|---|
| committer | Markus Everling <markuseverling@gmail.com> | 2023-05-07 00:11:56 +0000 |
| commit | 4967f25f6bf930a5f79d5c66f2ffc53159d43c4a (patch) | |
| tree | 4d788435018b2d47ca6b4805a8222a6dffb67d74 | |
| parent | 195d4cad50c5b8a544de608295e7fdc369f99d9a (diff) | |
| download | rust-4967f25f6bf930a5f79d5c66f2ffc53159d43c4a.tar.gz rust-4967f25f6bf930a5f79d5c66f2ffc53159d43c4a.zip | |
Use the new `load`/`store` functions in `{from,to}_slice`
| -rw-r--r-- | crates/core_simd/src/vector.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs index 92984f55e45..a793ae9e391 100644 --- a/crates/core_simd/src/vector.rs +++ b/crates/core_simd/src/vector.rs @@ -263,11 +263,9 @@ where slice.len() >= Self::N, "slice length must be at least the number of elements" ); - assert!(core::mem::size_of::<Self>() == Self::N * core::mem::size_of::<T>()); - // Safety: - // - We've checked the length is sufficient. - // - `T` and `Simd<T, N>` are Copy types. - unsafe { slice.as_ptr().cast::<Self>().read_unaligned() } + // SAFETY: We just checked that the slice contains + // at least `N` elements. + unsafe { Self::load(slice.as_ptr().cast()) } } /// Writes a SIMD vector to the first `N` elements of a slice. @@ -293,11 +291,9 @@ where slice.len() >= Self::N, "slice length must be at least the number of elements" ); - assert!(core::mem::size_of::<Self>() == Self::N * core::mem::size_of::<T>()); - // Safety: - // - We've checked the length is sufficient - // - `T` and `Simd<T, N>` are Copy types. - unsafe { slice.as_mut_ptr().cast::<Self>().write_unaligned(self) } + // SAFETY: We just checked that the slice contains + // at least `N` elements. + unsafe { self.store(slice.as_mut_ptr().cast()) } } /// Performs elementwise conversion of a SIMD vector's elements to another SIMD-valid type. |
