@@ -184,12 +184,15 @@ where
184184 /// # Safety
185185 /// Reading `ptr` must be safe, as if by `<*const [T; N]>::read_unaligned`.
186186 const unsafe fn load ( ptr : * const [ T ; N ] ) -> Self {
187- let mut tmp = core:: mem:: MaybeUninit :: uninit ( ) ;
187+ // There are potentially simpler ways to write this function, but this should result in
188+ // LLVM `load <N x T>`
189+
190+ let mut tmp = core:: mem:: MaybeUninit :: < Self > :: uninit ( ) ;
188191 // SAFETY: `Simd<T, N>` always contains `N` elements of type `T`. It may have padding
189192 // which does not need to be initialized. The safety of reading `ptr` is ensured by the
190193 // caller.
191194 unsafe {
192- core:: ptr:: copy_nonoverlapping ( ptr, tmp. as_mut_ptr ( ) as * mut _ , 1 ) ;
195+ core:: ptr:: copy_nonoverlapping ( ptr, tmp. as_mut_ptr ( ) . cast ( ) , 1 ) ;
193196 tmp. assume_init ( )
194197 }
195198 }
@@ -201,9 +204,14 @@ where
201204 /// # Safety
202205 /// Writing to `ptr` must be safe, as if by `<*mut [T; N]>::write_unaligned`.
203206 const unsafe fn store ( self , ptr : * mut [ T ; N ] ) {
207+ // There are potentially simpler ways to write this function, but this should result in
208+ // LLVM `store <N x T>`
209+
210+ // Creating a temporary helps LLVM turn the memcpy into a store.
211+ let tmp = self ;
204212 // SAFETY: `Simd<T, N>` always contains `N` elements of type `T`. The safety of writing
205213 // `ptr` is ensured by the caller.
206- unsafe { core:: ptr:: copy_nonoverlapping ( self . as_array ( ) , ptr, 1 ) }
214+ unsafe { core:: ptr:: copy_nonoverlapping ( tmp . as_array ( ) , ptr, 1 ) }
207215 }
208216
209217 /// Converts an array to a SIMD vector.
0 commit comments