@@ -184,28 +184,16 @@ where
184
184
/// # Safety
185
185
/// Reading `ptr` must be safe, as if by `<*const [T; N]>::read_unaligned`.
186
186
const unsafe fn load ( ptr : * const [ T ; N ] ) -> Self {
187
- let mut tmp = core:: mem:: MaybeUninit :: uninit ( ) ;
187
+ let mut tmp = core:: mem:: MaybeUninit :: < Self > :: uninit ( ) ;
188
188
// SAFETY: `Simd<T, N>` always contains `N` elements of type `T`. It may have padding
189
189
// which does not need to be initialized. The safety of reading `ptr` is ensured by the
190
190
// caller.
191
191
unsafe {
192
- core:: ptr:: copy_nonoverlapping ( ptr, tmp. as_mut_ptr ( ) as * mut _ , 1 ) ;
192
+ core:: ptr:: copy_nonoverlapping ( ptr, tmp. as_mut_ptr ( ) . cast ( ) , 1 ) ;
193
193
tmp. assume_init ( )
194
194
}
195
195
}
196
196
197
- /// Store a vector to an array of `T`.
198
- ///
199
- /// See `load` as to why this function is necessary.
200
- ///
201
- /// # Safety
202
- /// Writing to `ptr` must be safe, as if by `<*mut [T; N]>::write_unaligned`.
203
- const unsafe fn store ( self , ptr : * mut [ T ; N ] ) {
204
- // SAFETY: `Simd<T, N>` always contains `N` elements of type `T`. The safety of writing
205
- // `ptr` is ensured by the caller.
206
- unsafe { core:: ptr:: copy_nonoverlapping ( self . as_array ( ) , ptr, 1 ) }
207
- }
208
-
209
197
/// Converts an array to a SIMD vector.
210
198
pub const fn from_array ( array : [ T ; N ] ) -> Self {
211
199
// SAFETY: `&array` is safe to read.
@@ -220,18 +208,7 @@ where
220
208
221
209
/// Converts a SIMD vector to an array.
222
210
pub const fn to_array ( self ) -> [ T ; N ] {
223
- let mut tmp = core:: mem:: MaybeUninit :: uninit ( ) ;
224
- // SAFETY: writing to `tmp` is safe and initializes it.
225
- //
226
- // FIXME: We currently use a pointer store instead of `transmute_copy` because `repr(simd)`
227
- // results in padding for non-power-of-2 vectors (so vectors are larger than arrays).
228
- //
229
- // NOTE: This deliberately doesn't just use `self.0`, see the comment
230
- // on the struct definition for details.
231
- unsafe {
232
- self . store ( tmp. as_mut_ptr ( ) ) ;
233
- tmp. assume_init ( )
234
- }
211
+ * self . as_array ( )
235
212
}
236
213
237
214
/// Converts a slice to a SIMD vector containing `slice[..N]`.
0 commit comments