diff options
| author | Caleb Zulawski <caleb.zulawski@gmail.com> | 2023-05-07 08:16:26 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-07 08:16:26 -0400 |
| commit | 50416fcc2c8b1b5ea8c486cc3a624abefdee4f3f (patch) | |
| tree | c568d5babe5363cdfd638eb5065f98f99d066f3f | |
| parent | 45413e468d511195ab7b420a01415be008b49195 (diff) | |
| parent | 4967f25f6bf930a5f79d5c66f2ffc53159d43c4a (diff) | |
| download | rust-50416fcc2c8b1b5ea8c486cc3a624abefdee4f3f.tar.gz rust-50416fcc2c8b1b5ea8c486cc3a624abefdee4f3f.zip | |
Merge pull request #345 from Sp00ph/from_to_slice
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 ff761fc900f..0253f122c98 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. |
