@@ -112,10 +112,11 @@ static bool extractConstantMask(const Constant *C, unsigned MaskEltSizeInBits,
112
112
return true ;
113
113
}
114
114
115
- void DecodePSHUFBMask (const Constant *C, unsigned Width,
116
- SmallVectorImpl<int > &ShuffleMask) {
117
- assert ((Width == 128 || Width == 256 || Width == 512 ) &&
118
- C->getType ()->getPrimitiveSizeInBits () >= Width &&
115
+ void DecodePSHUFBMask (const Constant *C, SmallVectorImpl<int > &ShuffleMask) {
116
+ Type *MaskTy = C->getType ();
117
+ unsigned MaskTySize = MaskTy->getPrimitiveSizeInBits ();
118
+ (void )MaskTySize;
119
+ assert ((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512 ) &&
119
120
" Unexpected vector size." );
120
121
121
122
// The shuffle mask requires a byte vector.
@@ -124,7 +125,7 @@ void DecodePSHUFBMask(const Constant *C, unsigned Width,
124
125
if (!extractConstantMask (C, 8 , UndefElts, RawMask))
125
126
return ;
126
127
127
- unsigned NumElts = Width / 8 ;
128
+ unsigned NumElts = RawMask. size () ;
128
129
assert ((NumElts == 16 || NumElts == 32 || NumElts == 64 ) &&
129
130
" Unexpected number of vector elements." );
130
131
@@ -150,10 +151,12 @@ void DecodePSHUFBMask(const Constant *C, unsigned Width,
150
151
}
151
152
}
152
153
153
- void DecodeVPERMILPMask (const Constant *C, unsigned ElSize, unsigned Width,
154
+ void DecodeVPERMILPMask (const Constant *C, unsigned ElSize,
154
155
SmallVectorImpl<int > &ShuffleMask) {
155
- assert ((Width == 128 || Width == 256 || Width == 512 ) &&
156
- C->getType ()->getPrimitiveSizeInBits () >= Width &&
156
+ Type *MaskTy = C->getType ();
157
+ unsigned MaskTySize = MaskTy->getPrimitiveSizeInBits ();
158
+ (void )MaskTySize;
159
+ assert ((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512 ) &&
157
160
" Unexpected vector size." );
158
161
assert ((ElSize == 32 || ElSize == 64 ) && " Unexpected vector element size." );
159
162
@@ -163,7 +166,7 @@ void DecodeVPERMILPMask(const Constant *C, unsigned ElSize, unsigned Width,
163
166
if (!extractConstantMask (C, ElSize, UndefElts, RawMask))
164
167
return ;
165
168
166
- unsigned NumElts = Width / ElSize ;
169
+ unsigned NumElts = RawMask. size () ;
167
170
unsigned NumEltsPerLane = 128 / ElSize;
168
171
assert ((NumElts == 2 || NumElts == 4 || NumElts == 8 || NumElts == 16 ) &&
169
172
" Unexpected number of vector elements." );
@@ -186,21 +189,19 @@ void DecodeVPERMILPMask(const Constant *C, unsigned ElSize, unsigned Width,
186
189
}
187
190
188
191
void DecodeVPERMIL2PMask (const Constant *C, unsigned M2Z, unsigned ElSize,
189
- unsigned Width,
190
192
SmallVectorImpl<int > &ShuffleMask) {
191
193
Type *MaskTy = C->getType ();
192
194
unsigned MaskTySize = MaskTy->getPrimitiveSizeInBits ();
193
195
(void )MaskTySize;
194
- assert ((MaskTySize == 128 || MaskTySize == 256 ) &&
195
- Width >= MaskTySize && " Unexpected vector size." );
196
+ assert ((MaskTySize == 128 || MaskTySize == 256 ) && " Unexpected vector size." );
196
197
197
198
// The shuffle mask requires elements the same size as the target.
198
199
APInt UndefElts;
199
200
SmallVector<uint64_t , 8 > RawMask;
200
201
if (!extractConstantMask (C, ElSize, UndefElts, RawMask))
201
202
return ;
202
203
203
- unsigned NumElts = Width / ElSize ;
204
+ unsigned NumElts = RawMask. size () ;
204
205
unsigned NumEltsPerLane = 128 / ElSize;
205
206
assert ((NumElts == 2 || NumElts == 4 || NumElts == 8 ) &&
206
207
" Unexpected number of vector elements." );
@@ -241,20 +242,17 @@ void DecodeVPERMIL2PMask(const Constant *C, unsigned M2Z, unsigned ElSize,
241
242
}
242
243
}
243
244
244
- void DecodeVPPERMMask (const Constant *C, unsigned Width,
245
- SmallVectorImpl<int > &ShuffleMask) {
246
- Type *MaskTy = C->getType ();
247
- unsigned MaskTySize = MaskTy->getPrimitiveSizeInBits ();
248
- (void )MaskTySize;
249
- assert (Width == 128 && Width >= MaskTySize && " Unexpected vector size." );
245
+ void DecodeVPPERMMask (const Constant *C, SmallVectorImpl<int > &ShuffleMask) {
246
+ assert (C->getType ()->getPrimitiveSizeInBits () == 128 &&
247
+ " Unexpected vector size." );
250
248
251
249
// The shuffle mask requires a byte vector.
252
250
APInt UndefElts;
253
251
SmallVector<uint64_t , 16 > RawMask;
254
252
if (!extractConstantMask (C, 8 , UndefElts, RawMask))
255
253
return ;
256
254
257
- unsigned NumElts = Width / 8 ;
255
+ unsigned NumElts = RawMask. size () ;
258
256
assert (NumElts == 16 && " Unexpected number of vector elements." );
259
257
260
258
for (unsigned i = 0 ; i != NumElts; ++i) {
@@ -293,10 +291,12 @@ void DecodeVPPERMMask(const Constant *C, unsigned Width,
293
291
}
294
292
}
295
293
296
- void DecodeVPERMVMask (const Constant *C, unsigned ElSize, unsigned Width,
294
+ void DecodeVPERMVMask (const Constant *C, unsigned ElSize,
297
295
SmallVectorImpl<int > &ShuffleMask) {
298
- assert ((Width == 128 || Width == 256 || Width == 512 ) &&
299
- C->getType ()->getPrimitiveSizeInBits () >= Width &&
296
+ Type *MaskTy = C->getType ();
297
+ unsigned MaskTySize = MaskTy->getPrimitiveSizeInBits ();
298
+ (void )MaskTySize;
299
+ assert ((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512 ) &&
300
300
" Unexpected vector size." );
301
301
assert ((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64 ) &&
302
302
" Unexpected vector element size." );
@@ -307,7 +307,7 @@ void DecodeVPERMVMask(const Constant *C, unsigned ElSize, unsigned Width,
307
307
if (!extractConstantMask (C, ElSize, UndefElts, RawMask))
308
308
return ;
309
309
310
- unsigned NumElts = Width / ElSize ;
310
+ unsigned NumElts = RawMask. size () ;
311
311
312
312
for (unsigned i = 0 ; i != NumElts; ++i) {
313
313
if (UndefElts[i]) {
@@ -319,10 +319,12 @@ void DecodeVPERMVMask(const Constant *C, unsigned ElSize, unsigned Width,
319
319
}
320
320
}
321
321
322
- void DecodeVPERMV3Mask (const Constant *C, unsigned ElSize, unsigned Width,
322
+ void DecodeVPERMV3Mask (const Constant *C, unsigned ElSize,
323
323
SmallVectorImpl<int > &ShuffleMask) {
324
- assert ((Width == 128 || Width == 256 || Width == 512 ) &&
325
- C->getType ()->getPrimitiveSizeInBits () >= Width &&
324
+ Type *MaskTy = C->getType ();
325
+ unsigned MaskTySize = MaskTy->getPrimitiveSizeInBits ();
326
+ (void )MaskTySize;
327
+ assert ((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512 ) &&
326
328
" Unexpected vector size." );
327
329
assert ((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64 ) &&
328
330
" Unexpected vector element size." );
@@ -333,7 +335,7 @@ void DecodeVPERMV3Mask(const Constant *C, unsigned ElSize, unsigned Width,
333
335
if (!extractConstantMask (C, ElSize, UndefElts, RawMask))
334
336
return ;
335
337
336
- unsigned NumElts = Width / ElSize ;
338
+ unsigned NumElts = RawMask. size () ;
337
339
338
340
for (unsigned i = 0 ; i != NumElts; ++i) {
339
341
if (UndefElts[i]) {
0 commit comments