@@ -69,12 +69,12 @@ pub macro simd_swizzle {
69
69
}
70
70
}
71
71
72
- /// Create a vector from the elements of another vector.
72
+ /// Creates a vector from the elements of another vector.
73
73
pub trait Swizzle < const N : usize > {
74
74
/// Map from the elements of the input vector to the output vector.
75
75
const INDEX : [ usize ; N ] ;
76
76
77
- /// Create a new vector from the elements of `vector`.
77
+ /// Creates a new vector from the elements of `vector`.
78
78
///
79
79
/// Lane `i` of the output is `vector[Self::INDEX[i]]`.
80
80
#[ inline]
@@ -85,7 +85,7 @@ pub trait Swizzle<const N: usize> {
85
85
LaneCount < N > : SupportedLaneCount ,
86
86
LaneCount < M > : SupportedLaneCount ,
87
87
{
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.
89
89
unsafe {
90
90
core:: intrinsics:: simd:: simd_shuffle (
91
91
vector,
@@ -103,13 +103,17 @@ pub trait Swizzle<const N: usize> {
103
103
output[ i] = index as u32 ;
104
104
i += 1 ;
105
105
}
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)
107
111
} ,
108
112
)
109
113
}
110
114
}
111
115
112
- /// Create a new vector from the elements of `first` and `second`.
116
+ /// Creates a new vector from the elements of `first` and `second`.
113
117
///
114
118
/// Lane `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
115
119
/// `first` and `second`.
@@ -121,7 +125,7 @@ pub trait Swizzle<const N: usize> {
121
125
LaneCount < N > : SupportedLaneCount ,
122
126
LaneCount < M > : SupportedLaneCount ,
123
127
{
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.
125
129
unsafe {
126
130
core:: intrinsics:: simd:: simd_shuffle (
127
131
first,
@@ -139,13 +143,17 @@ pub trait Swizzle<const N: usize> {
139
143
output[ i] = index as u32 ;
140
144
i += 1 ;
141
145
}
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)
143
151
} ,
144
152
)
145
153
}
146
154
}
147
155
148
- /// Create a new mask from the elements of `mask`.
156
+ /// Creates a new mask from the elements of `mask`.
149
157
///
150
158
/// Element `i` of the output is `mask[Self::INDEX[i]]`.
151
159
#[ inline]
@@ -160,7 +168,7 @@ pub trait Swizzle<const N: usize> {
160
168
unsafe { Mask :: from_int_unchecked ( Self :: swizzle ( mask. to_int ( ) ) ) }
161
169
}
162
170
163
- /// Create a new mask from the elements of `first` and `second`.
171
+ /// Creates a new mask from the elements of `first` and `second`.
164
172
///
165
173
/// Element `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
166
174
/// `first` and `second`.
0 commit comments