1 //===-- X86ShuffleDecode.cpp - X86 shuffle decode logic -------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Define several functions to decode x86 specific shuffle semantics into a
11 // generic vector mask.
13 //===----------------------------------------------------------------------===//
15 #include "X86ShuffleDecode.h"
16 #include "llvm/IR/Constants.h"
17 #include "llvm/CodeGen/MachineValueType.h"
19 //===----------------------------------------------------------------------===//
20 // Vector Mask Decoding
21 //===----------------------------------------------------------------------===//
25 void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask) {
26 // Defaults the copying the dest value.
27 ShuffleMask.push_back(0);
28 ShuffleMask.push_back(1);
29 ShuffleMask.push_back(2);
30 ShuffleMask.push_back(3);
32 // Decode the immediate.
33 unsigned ZMask = Imm & 15;
34 unsigned CountD = (Imm >> 4) & 3;
35 unsigned CountS = (Imm >> 6) & 3;
37 // CountS selects which input element to use.
38 unsigned InVal = 4 + CountS;
39 // CountD specifies which element of destination to update.
40 ShuffleMask[CountD] = InVal;
41 // ZMask zaps values, potentially overriding the CountD elt.
42 if (ZMask & 1) ShuffleMask[0] = SM_SentinelZero;
43 if (ZMask & 2) ShuffleMask[1] = SM_SentinelZero;
44 if (ZMask & 4) ShuffleMask[2] = SM_SentinelZero;
45 if (ZMask & 8) ShuffleMask[3] = SM_SentinelZero;
49 void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask) {
50 for (unsigned i = NElts / 2; i != NElts; ++i)
51 ShuffleMask.push_back(NElts + i);
53 for (unsigned i = NElts / 2; i != NElts; ++i)
54 ShuffleMask.push_back(i);
58 void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask) {
59 for (unsigned i = 0; i != NElts / 2; ++i)
60 ShuffleMask.push_back(i);
62 for (unsigned i = 0; i != NElts / 2; ++i)
63 ShuffleMask.push_back(NElts + i);
66 void DecodeMOVSLDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask) {
67 unsigned NumElts = VT.getVectorNumElements();
68 for (int i = 0, e = NumElts / 2; i < e; ++i) {
69 ShuffleMask.push_back(2 * i);
70 ShuffleMask.push_back(2 * i);
74 void DecodeMOVSHDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask) {
75 unsigned NumElts = VT.getVectorNumElements();
76 for (int i = 0, e = NumElts / 2; i < e; ++i) {
77 ShuffleMask.push_back(2 * i + 1);
78 ShuffleMask.push_back(2 * i + 1);
82 void DecodeMOVDDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask) {
83 unsigned VectorSizeInBits = VT.getSizeInBits();
84 unsigned ScalarSizeInBits = VT.getScalarSizeInBits();
85 unsigned NumElts = VT.getVectorNumElements();
86 unsigned NumLanes = VectorSizeInBits / 128;
87 unsigned NumLaneElts = NumElts / NumLanes;
88 unsigned NumLaneSubElts = 64 / ScalarSizeInBits;
90 for (unsigned l = 0; l < NumElts; l += NumLaneElts)
91 for (unsigned i = 0; i < NumLaneElts; i += NumLaneSubElts)
92 for (unsigned s = 0; s != NumLaneSubElts; s++)
93 ShuffleMask.push_back(l + s);
96 void DecodePSLLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask) {
97 unsigned VectorSizeInBits = VT.getSizeInBits();
98 unsigned NumElts = VectorSizeInBits / 8;
99 unsigned NumLanes = VectorSizeInBits / 128;
100 unsigned NumLaneElts = NumElts / NumLanes;
102 for (unsigned l = 0; l < NumElts; l += NumLaneElts)
103 for (unsigned i = 0; i < NumLaneElts; ++i) {
104 int M = SM_SentinelZero;
105 if (i >= Imm) M = i - Imm + l;
106 ShuffleMask.push_back(M);
110 void DecodePSRLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask) {
111 unsigned VectorSizeInBits = VT.getSizeInBits();
112 unsigned NumElts = VectorSizeInBits / 8;
113 unsigned NumLanes = VectorSizeInBits / 128;
114 unsigned NumLaneElts = NumElts / NumLanes;
116 for (unsigned l = 0; l < NumElts; l += NumLaneElts)
117 for (unsigned i = 0; i < NumLaneElts; ++i) {
118 unsigned Base = i + Imm;
120 if (Base >= NumLaneElts) M = SM_SentinelZero;
121 ShuffleMask.push_back(M);
125 void DecodePALIGNRMask(MVT VT, unsigned Imm,
126 SmallVectorImpl<int> &ShuffleMask) {
127 unsigned NumElts = VT.getVectorNumElements();
128 unsigned Offset = Imm * (VT.getVectorElementType().getSizeInBits() / 8);
130 unsigned NumLanes = VT.getSizeInBits() / 128;
131 unsigned NumLaneElts = NumElts / NumLanes;
133 for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
134 for (unsigned i = 0; i != NumLaneElts; ++i) {
135 unsigned Base = i + Offset;
136 // if i+offset is out of this lane then we actually need the other source
137 if (Base >= NumLaneElts) Base += NumElts - NumLaneElts;
138 ShuffleMask.push_back(Base + l);
143 /// DecodePSHUFMask - This decodes the shuffle masks for pshufw, pshufd, and vpermilp*.
144 /// VT indicates the type of the vector allowing it to handle different
145 /// datatypes and vector widths.
146 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask) {
147 unsigned NumElts = VT.getVectorNumElements();
149 unsigned NumLanes = VT.getSizeInBits() / 128;
150 if (NumLanes == 0) NumLanes = 1; // Handle MMX
151 unsigned NumLaneElts = NumElts / NumLanes;
153 unsigned NewImm = Imm;
154 for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
155 for (unsigned i = 0; i != NumLaneElts; ++i) {
156 ShuffleMask.push_back(NewImm % NumLaneElts + l);
157 NewImm /= NumLaneElts;
159 if (NumLaneElts == 4) NewImm = Imm; // reload imm
163 void DecodePSHUFHWMask(MVT VT, unsigned Imm,
164 SmallVectorImpl<int> &ShuffleMask) {
165 unsigned NumElts = VT.getVectorNumElements();
167 for (unsigned l = 0; l != NumElts; l += 8) {
168 unsigned NewImm = Imm;
169 for (unsigned i = 0, e = 4; i != e; ++i) {
170 ShuffleMask.push_back(l + i);
172 for (unsigned i = 4, e = 8; i != e; ++i) {
173 ShuffleMask.push_back(l + 4 + (NewImm & 3));
179 void DecodePSHUFLWMask(MVT VT, unsigned Imm,
180 SmallVectorImpl<int> &ShuffleMask) {
181 unsigned NumElts = VT.getVectorNumElements();
183 for (unsigned l = 0; l != NumElts; l += 8) {
184 unsigned NewImm = Imm;
185 for (unsigned i = 0, e = 4; i != e; ++i) {
186 ShuffleMask.push_back(l + (NewImm & 3));
189 for (unsigned i = 4, e = 8; i != e; ++i) {
190 ShuffleMask.push_back(l + i);
195 void DecodePSWAPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask) {
196 unsigned NumElts = VT.getVectorNumElements();
197 unsigned NumHalfElts = NumElts / 2;
199 for (unsigned l = 0; l != NumHalfElts; ++l)
200 ShuffleMask.push_back(l + NumHalfElts);
201 for (unsigned h = 0; h != NumHalfElts; ++h)
202 ShuffleMask.push_back(h);
205 /// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
206 /// the type of the vector allowing it to handle different datatypes and vector
208 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask) {
209 unsigned NumElts = VT.getVectorNumElements();
211 unsigned NumLanes = VT.getSizeInBits() / 128;
212 unsigned NumLaneElts = NumElts / NumLanes;
214 unsigned NewImm = Imm;
215 for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
216 // each half of a lane comes from different source
217 for (unsigned s = 0; s != NumElts * 2; s += NumElts) {
218 for (unsigned i = 0; i != NumLaneElts / 2; ++i) {
219 ShuffleMask.push_back(NewImm % NumLaneElts + s + l);
220 NewImm /= NumLaneElts;
223 if (NumLaneElts == 4) NewImm = Imm; // reload imm
227 /// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
228 /// and punpckh*. VT indicates the type of the vector allowing it to handle
229 /// different datatypes and vector widths.
230 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask) {
231 unsigned NumElts = VT.getVectorNumElements();
233 // Handle 128 and 256-bit vector lengths. AVX defines UNPCK* to operate
234 // independently on 128-bit lanes.
235 unsigned NumLanes = VT.getSizeInBits() / 128;
236 if (NumLanes == 0) NumLanes = 1; // Handle MMX
237 unsigned NumLaneElts = NumElts / NumLanes;
239 for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
240 for (unsigned i = l + NumLaneElts / 2, e = l + NumLaneElts; i != e; ++i) {
241 ShuffleMask.push_back(i); // Reads from dest/src1
242 ShuffleMask.push_back(i + NumElts); // Reads from src/src2
247 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
248 /// and punpckl*. VT indicates the type of the vector allowing it to handle
249 /// different datatypes and vector widths.
250 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask) {
251 unsigned NumElts = VT.getVectorNumElements();
253 // Handle 128 and 256-bit vector lengths. AVX defines UNPCK* to operate
254 // independently on 128-bit lanes.
255 unsigned NumLanes = VT.getSizeInBits() / 128;
256 if (NumLanes == 0 ) NumLanes = 1; // Handle MMX
257 unsigned NumLaneElts = NumElts / NumLanes;
259 for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
260 for (unsigned i = l, e = l + NumLaneElts / 2; i != e; ++i) {
261 ShuffleMask.push_back(i); // Reads from dest/src1
262 ShuffleMask.push_back(i + NumElts); // Reads from src/src2
267 /// \brief Decode a shuffle packed values at 128-bit granularity
268 /// (SHUFF32x4/SHUFF64x2/SHUFI32x4/SHUFI64x2)
269 /// immediate mask into a shuffle mask.
270 void decodeVSHUF64x2FamilyMask(MVT VT, unsigned Imm,
271 SmallVectorImpl<int> &ShuffleMask) {
272 unsigned NumLanes = VT.getSizeInBits() / 128;
273 unsigned NumElementsInLane = 128 / VT.getScalarSizeInBits();
274 unsigned ControlBitsMask = NumLanes - 1;
275 unsigned NumControlBits = NumLanes / 2;
277 for (unsigned l = 0; l != NumLanes; ++l) {
278 unsigned LaneMask = (Imm >> (l * NumControlBits)) & ControlBitsMask;
279 // We actually need the other source.
280 if (l >= NumLanes / 2)
281 LaneMask += NumLanes;
282 for (unsigned i = 0; i != NumElementsInLane; ++i)
283 ShuffleMask.push_back(LaneMask * NumElementsInLane + i);
287 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
288 SmallVectorImpl<int> &ShuffleMask) {
289 unsigned HalfSize = VT.getVectorNumElements() / 2;
291 for (unsigned l = 0; l != 2; ++l) {
292 unsigned HalfMask = Imm >> (l * 4);
293 unsigned HalfBegin = (HalfMask & 0x3) * HalfSize;
294 for (unsigned i = HalfBegin, e = HalfBegin + HalfSize; i != e; ++i)
295 ShuffleMask.push_back(HalfMask & 8 ? SM_SentinelZero : (int)i);
299 void DecodePSHUFBMask(const Constant *C, SmallVectorImpl<int> &ShuffleMask) {
300 Type *MaskTy = C->getType();
301 // It is not an error for the PSHUFB mask to not be a vector of i8 because the
302 // constant pool uniques constants by their bit representation.
303 // e.g. the following take up the same space in the constant pool:
304 // i128 -170141183420855150465331762880109871104
306 // <2 x i64> <i64 -9223372034707292160, i64 -9223372034707292160>
308 // <4 x i32> <i32 -2147483648, i32 -2147483648,
309 // i32 -2147483648, i32 -2147483648>
311 unsigned MaskTySize = MaskTy->getPrimitiveSizeInBits();
313 if (MaskTySize != 128 && MaskTySize != 256) // FIXME: Add support for AVX-512.
316 // This is a straightforward byte vector.
317 if (MaskTy->isVectorTy() && MaskTy->getVectorElementType()->isIntegerTy(8)) {
318 int NumElements = MaskTy->getVectorNumElements();
319 ShuffleMask.reserve(NumElements);
321 for (int i = 0; i < NumElements; ++i) {
322 // For AVX vectors with 32 bytes the base of the shuffle is the 16-byte
323 // lane of the vector we're inside.
324 int Base = i < 16 ? 0 : 16;
325 Constant *COp = C->getAggregateElement(i);
329 } else if (isa<UndefValue>(COp)) {
330 ShuffleMask.push_back(SM_SentinelUndef);
333 uint64_t Element = cast<ConstantInt>(COp)->getZExtValue();
334 // If the high bit (7) of the byte is set, the element is zeroed.
335 if (Element & (1 << 7))
336 ShuffleMask.push_back(SM_SentinelZero);
338 // Only the least significant 4 bits of the byte are used.
339 int Index = Base + (Element & 0xf);
340 ShuffleMask.push_back(Index);
344 // TODO: Handle funny-looking vectors too.
347 void DecodePSHUFBMask(ArrayRef<uint64_t> RawMask,
348 SmallVectorImpl<int> &ShuffleMask) {
349 for (int i = 0, e = RawMask.size(); i < e; ++i) {
350 uint64_t M = RawMask[i];
351 if (M == (uint64_t)SM_SentinelUndef) {
352 ShuffleMask.push_back(M);
355 // For AVX vectors with 32 bytes the base of the shuffle is the half of
356 // the vector we're inside.
357 int Base = i < 16 ? 0 : 16;
358 // If the high bit (7) of the byte is set, the element is zeroed.
360 ShuffleMask.push_back(SM_SentinelZero);
362 // Only the least significant 4 bits of the byte are used.
363 int Index = Base + (M & 0xf);
364 ShuffleMask.push_back(Index);
369 void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask) {
370 int ElementBits = VT.getScalarSizeInBits();
371 int NumElements = VT.getVectorNumElements();
372 for (int i = 0; i < NumElements; ++i) {
373 // If there are more than 8 elements in the vector, then any immediate blend
374 // mask applies to each 128-bit lane. There can never be more than
375 // 8 elements in a 128-bit lane with an immediate blend.
376 int Bit = NumElements > 8 ? i % (128 / ElementBits) : i;
378 "Immediate blends only operate over 8 elements at a time!");
379 ShuffleMask.push_back(((Imm >> Bit) & 1) ? NumElements + i : i);
383 /// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
384 /// No VT provided since it only works on 256-bit, 4 element vectors.
385 void DecodeVPERMMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask) {
386 for (unsigned i = 0; i != 4; ++i) {
387 ShuffleMask.push_back((Imm >> (2 * i)) & 3);
391 void DecodeVPERMILPMask(const Constant *C, unsigned ElSize,
392 SmallVectorImpl<int> &ShuffleMask) {
393 Type *MaskTy = C->getType();
394 // It is not an error for the PSHUFB mask to not be a vector of i8 because the
395 // constant pool uniques constants by their bit representation.
396 // e.g. the following take up the same space in the constant pool:
397 // i128 -170141183420855150465331762880109871104
399 // <2 x i64> <i64 -9223372034707292160, i64 -9223372034707292160>
401 // <4 x i32> <i32 -2147483648, i32 -2147483648,
402 // i32 -2147483648, i32 -2147483648>
404 unsigned MaskTySize = MaskTy->getPrimitiveSizeInBits();
406 if (MaskTySize != 128 && MaskTySize != 256) // FIXME: Add support for AVX-512.
409 // Only support vector types.
410 if (!MaskTy->isVectorTy())
413 // Make sure its an integer type.
414 Type *VecEltTy = MaskTy->getVectorElementType();
415 if (!VecEltTy->isIntegerTy())
418 // Support any element type from byte up to element size.
419 // This is necesary primarily because 64-bit elements get split to 32-bit
420 // in the constant pool on 32-bit target.
421 unsigned EltTySize = VecEltTy->getIntegerBitWidth();
422 if (EltTySize < 8 || EltTySize > ElSize)
425 unsigned NumElements = MaskTySize / ElSize;
426 assert((NumElements == 2 || NumElements == 4 || NumElements == 8) &&
427 "Unexpected number of vector elements.");
428 ShuffleMask.reserve(NumElements);
429 unsigned NumElementsPerLane = 128 / ElSize;
430 unsigned Factor = ElSize / EltTySize;
432 for (unsigned i = 0; i < NumElements; ++i) {
433 Constant *COp = C->getAggregateElement(i * Factor);
437 } else if (isa<UndefValue>(COp)) {
438 ShuffleMask.push_back(SM_SentinelUndef);
441 int Index = i & ~(NumElementsPerLane - 1);
442 uint64_t Element = cast<ConstantInt>(COp)->getZExtValue();
444 Index += (Element >> 1) & 0x1;
446 Index += Element & 0x3;
447 ShuffleMask.push_back(Index);
450 // TODO: Handle funny-looking vectors too.
453 void DecodeZeroExtendMask(MVT SrcVT, MVT DstVT, SmallVectorImpl<int> &Mask) {
454 unsigned NumDstElts = DstVT.getVectorNumElements();
455 unsigned SrcScalarBits = SrcVT.getScalarSizeInBits();
456 unsigned DstScalarBits = DstVT.getScalarSizeInBits();
457 unsigned Scale = DstScalarBits / SrcScalarBits;
458 assert(SrcScalarBits < DstScalarBits &&
459 "Expected zero extension mask to increase scalar size");
460 assert(SrcVT.getVectorNumElements() >= NumDstElts &&
461 "Too many zero extension lanes");
463 for (unsigned i = 0; i != NumDstElts; i++) {
465 for (unsigned j = 1; j != Scale; j++)
466 Mask.push_back(SM_SentinelZero);
470 void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl<int> &ShuffleMask) {
471 unsigned NumElts = VT.getVectorNumElements();
472 ShuffleMask.push_back(0);
473 for (unsigned i = 1; i < NumElts; i++)
474 ShuffleMask.push_back(SM_SentinelZero);
477 void DecodeScalarMoveMask(MVT VT, bool IsLoad, SmallVectorImpl<int> &Mask) {
478 // First element comes from the first element of second source.
479 // Remaining elements: Load zero extends / Move copies from first source.
480 unsigned NumElts = VT.getVectorNumElements();
481 Mask.push_back(NumElts);
482 for (unsigned i = 1; i < NumElts; i++)
483 Mask.push_back(IsLoad ? static_cast<int>(SM_SentinelZero) : i);
486 void DecodeEXTRQIMask(int Len, int Idx,
487 SmallVectorImpl<int> &ShuffleMask) {
488 // Only the bottom 6 bits are valid for each immediate.
492 // We can only decode this bit extraction instruction as a shuffle if both the
493 // length and index work with whole bytes.
494 if (0 != (Len % 8) || 0 != (Idx % 8))
497 // A length of zero is equivalent to a bit length of 64.
501 // If the length + index exceeds the bottom 64 bits the result is undefined.
502 if ((Len + Idx) > 64) {
503 ShuffleMask.append(16, SM_SentinelUndef);
507 // Convert index and index to work with bytes.
511 // EXTRQ: Extract Len bytes starting from Idx. Zero pad the remaining bytes
512 // of the lower 64-bits. The upper 64-bits are undefined.
513 for (int i = 0; i != Len; ++i)
514 ShuffleMask.push_back(i + Idx);
515 for (int i = Len; i != 8; ++i)
516 ShuffleMask.push_back(SM_SentinelZero);
517 for (int i = 8; i != 16; ++i)
518 ShuffleMask.push_back(SM_SentinelUndef);
521 void DecodeINSERTQIMask(int Len, int Idx,
522 SmallVectorImpl<int> &ShuffleMask) {
523 // Only the bottom 6 bits are valid for each immediate.
527 // We can only decode this bit insertion instruction as a shuffle if both the
528 // length and index work with whole bytes.
529 if (0 != (Len % 8) || 0 != (Idx % 8))
532 // A length of zero is equivalent to a bit length of 64.
536 // If the length + index exceeds the bottom 64 bits the result is undefined.
537 if ((Len + Idx) > 64) {
538 ShuffleMask.append(16, SM_SentinelUndef);
542 // Convert index and index to work with bytes.
546 // INSERTQ: Extract lowest Len bytes from lower half of second source and
547 // insert over first source starting at Idx byte. The upper 64-bits are
549 for (int i = 0; i != Idx; ++i)
550 ShuffleMask.push_back(i);
551 for (int i = 0; i != Len; ++i)
552 ShuffleMask.push_back(i + 16);
553 for (int i = Idx + Len; i != 8; ++i)
554 ShuffleMask.push_back(i);
555 for (int i = 8; i != 16; ++i)
556 ShuffleMask.push_back(SM_SentinelUndef);
559 void DecodeVPERMVMask(ArrayRef<uint64_t> RawMask,
560 SmallVectorImpl<int> &ShuffleMask) {
561 for (int i = 0, e = RawMask.size(); i < e; ++i) {
562 uint64_t M = RawMask[i];
563 ShuffleMask.push_back((int)M);
567 void DecodeVPERMV3Mask(ArrayRef<uint64_t> RawMask,
568 SmallVectorImpl<int> &ShuffleMask) {
569 for (int i = 0, e = RawMask.size(); i < e; ++i) {
570 uint64_t M = RawMask[i];
571 ShuffleMask.push_back((int)M);
575 void DecodeVPERMVMask(const Constant *C, MVT VT,
576 SmallVectorImpl<int> &ShuffleMask) {
577 Type *MaskTy = C->getType();
578 if (MaskTy->isVectorTy()) {
579 unsigned NumElements = MaskTy->getVectorNumElements();
580 if (NumElements == VT.getVectorNumElements()) {
581 for (unsigned i = 0; i < NumElements; ++i) {
582 Constant *COp = C->getAggregateElement(i);
583 if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp))) {
587 if (isa<UndefValue>(COp))
588 ShuffleMask.push_back(SM_SentinelUndef);
590 uint64_t Element = cast<ConstantInt>(COp)->getZExtValue();
591 Element &= (1 << NumElements) - 1;
592 ShuffleMask.push_back(Element);
598 // Scalar value; just broadcast it
599 if (!isa<ConstantInt>(C))
601 uint64_t Element = cast<ConstantInt>(C)->getZExtValue();
602 int NumElements = VT.getVectorNumElements();
603 Element &= (1 << NumElements) - 1;
604 for (int i = 0; i < NumElements; ++i)
605 ShuffleMask.push_back(Element);
608 void DecodeVPERMV3Mask(const Constant *C, MVT VT,
609 SmallVectorImpl<int> &ShuffleMask) {
610 Type *MaskTy = C->getType();
611 unsigned NumElements = MaskTy->getVectorNumElements();
612 if (NumElements == VT.getVectorNumElements()) {
613 for (unsigned i = 0; i < NumElements; ++i) {
614 Constant *COp = C->getAggregateElement(i);
619 if (isa<UndefValue>(COp))
620 ShuffleMask.push_back(SM_SentinelUndef);
622 uint64_t Element = cast<ConstantInt>(COp)->getZExtValue();
623 Element &= (1 << NumElements*2) - 1;
624 ShuffleMask.push_back(Element);