@@ -69,12 +69,12 @@ pub macro simd_swizzle {
6969 }
7070}
7171
72- /// Create a vector from the elements of another vector.
72+ /// Creates a vector from the elements of another vector.
7373pub trait Swizzle < const N : usize > {
7474 /// Map from the elements of the input vector to the output vector.
7575 const INDEX : [ usize ; N ] ;
7676
77- /// Create a new vector from the elements of `vector`.
77+ /// Creates a new vector from the elements of `vector`.
7878 ///
7979 /// Lane `i` of the output is `vector[Self::INDEX[i]]`.
8080 #[ inline]
@@ -85,7 +85,7 @@ pub trait Swizzle<const N: usize> {
8585 LaneCount < N > : SupportedLaneCount ,
8686 LaneCount < M > : SupportedLaneCount ,
8787 {
88- // Safety: `vector` is a vector, and the index is a const array of u32.
88+ // Safety: `vector` is a vector, and the index is a const vector of u32.
8989 unsafe {
9090 core:: intrinsics:: simd:: simd_shuffle (
9191 vector,
@@ -103,13 +103,17 @@ pub trait Swizzle<const N: usize> {
103103 output[ i] = index as u32 ;
104104 i += 1 ;
105105 }
106- output
106+
107+ // The index list needs to be returned as a vector.
108+ #[ repr( simd) ]
109+ struct SimdShuffleIdx < const LEN : usize > ( [ u32 ; LEN ] ) ;
110+ SimdShuffleIdx ( output)
107111 } ,
108112 )
109113 }
110114 }
111115
112- /// Create a new vector from the elements of `first` and `second`.
116+ /// Creates a new vector from the elements of `first` and `second`.
113117 ///
114118 /// Lane `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
115119 /// `first` and `second`.
@@ -121,7 +125,7 @@ pub trait Swizzle<const N: usize> {
121125 LaneCount < N > : SupportedLaneCount ,
122126 LaneCount < M > : SupportedLaneCount ,
123127 {
124- // Safety: `first` and `second` are vectors, and the index is a const array of u32.
128+ // Safety: `first` and `second` are vectors, and the index is a const vector of u32.
125129 unsafe {
126130 core:: intrinsics:: simd:: simd_shuffle (
127131 first,
@@ -139,13 +143,17 @@ pub trait Swizzle<const N: usize> {
139143 output[ i] = index as u32 ;
140144 i += 1 ;
141145 }
142- output
146+
147+ // The index list needs to be returned as a vector.
148+ #[ repr( simd) ]
149+ struct SimdShuffleIdx < const LEN : usize > ( [ u32 ; LEN ] ) ;
150+ SimdShuffleIdx ( output)
143151 } ,
144152 )
145153 }
146154 }
147155
148- /// Create a new mask from the elements of `mask`.
156+ /// Creates a new mask from the elements of `mask`.
149157 ///
150158 /// Element `i` of the output is `mask[Self::INDEX[i]]`.
151159 #[ inline]
@@ -160,7 +168,7 @@ pub trait Swizzle<const N: usize> {
160168 unsafe { Mask :: from_int_unchecked ( Self :: swizzle ( mask. to_int ( ) ) ) }
161169 }
162170
163- /// Create a new mask from the elements of `first` and `second`.
171+ /// Creates a new mask from the elements of `first` and `second`.
164172 ///
165173 /// Element `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
166174 /// `first` and `second`.
0 commit comments