if (is128BitLaneRepeatedShuffleMask(VT, Mask))
return SDValue();
- int Size = Mask.size();
+ int NumElts = Mask.size();
int NumLanes = VT.getSizeInBits() / 128;
- int LaneSize = 128 / VT.getScalarSizeInBits();
- SmallVector<int, 16> RepeatMask(LaneSize, -1);
+ int NumLaneElts = 128 / VT.getScalarSizeInBits();
+ SmallVector<int, 16> RepeatMask(NumLaneElts, -1);
SmallVector<std::array<int, 2>, 2> LaneSrcs(NumLanes, {{-1, -1}});
// First pass will try to fill in the RepeatMask from lanes that need two
// sources.
for (int Lane = 0; Lane != NumLanes; ++Lane) {
- int Srcs[2] = { -1, -1 };
- SmallVector<int, 16> InLaneMask(LaneSize, -1);
- for (int i = 0; i != LaneSize; ++i) {
- int M = Mask[(Lane * LaneSize) + i];
+ int Srcs[2] = {-1, -1};
+ SmallVector<int, 16> InLaneMask(NumLaneElts, -1);
+ for (int i = 0; i != NumLaneElts; ++i) {
+ int M = Mask[(Lane * NumLaneElts) + i];
if (M < 0)
continue;
// Determine which of the possible input lanes (NumLanes from each source)
// this element comes from. Assign that as one of the sources for this
// lane. We can assign up to 2 sources for this lane. If we run out
// sources we can't do anything.
- int LaneSrc = M / LaneSize;
+ int LaneSrc = M / NumLaneElts;
int Src;
if (Srcs[0] < 0 || Srcs[0] == LaneSrc)
Src = 0;
return SDValue();
Srcs[Src] = LaneSrc;
- InLaneMask[i] = (M % LaneSize) + Src * Size;
+ InLaneMask[i] = (M % NumLaneElts) + Src * NumElts;
}
// If this lane has two sources, see if it fits with the repeat mask so far.
if (LaneSrcs[Lane][0] >= 0)
continue;
- for (int i = 0; i != LaneSize; ++i) {
- int M = Mask[(Lane * LaneSize) + i];
+ for (int i = 0; i != NumLaneElts; ++i) {
+ int M = Mask[(Lane * NumLaneElts) + i];
if (M < 0)
continue;
// If RepeatMask isn't defined yet we can define it ourself.
if (RepeatMask[i] < 0)
- RepeatMask[i] = M % LaneSize;
+ RepeatMask[i] = M % NumLaneElts;
- if (RepeatMask[i] < Size) {
- if (RepeatMask[i] != M % LaneSize)
+ if (RepeatMask[i] < NumElts) {
+ if (RepeatMask[i] != M % NumLaneElts)
return SDValue();
- LaneSrcs[Lane][0] = M / LaneSize;
+ LaneSrcs[Lane][0] = M / NumLaneElts;
} else {
- if (RepeatMask[i] != ((M % LaneSize) + Size))
+ if (RepeatMask[i] != ((M % NumLaneElts) + NumElts))
return SDValue();
- LaneSrcs[Lane][1] = M / LaneSize;
+ LaneSrcs[Lane][1] = M / NumLaneElts;
}
}
return SDValue();
}
- SmallVector<int, 16> NewMask(Size, -1);
+ SmallVector<int, 16> NewMask(NumElts, -1);
for (int Lane = 0; Lane != NumLanes; ++Lane) {
int Src = LaneSrcs[Lane][0];
- for (int i = 0; i != LaneSize; ++i) {
+ for (int i = 0; i != NumLaneElts; ++i) {
int M = -1;
if (Src >= 0)
- M = Src * LaneSize + i;
- NewMask[Lane * LaneSize + i] = M;
+ M = Src * NumLaneElts + i;
+ NewMask[Lane * NumLaneElts + i] = M;
}
}
SDValue NewV1 = DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
for (int Lane = 0; Lane != NumLanes; ++Lane) {
int Src = LaneSrcs[Lane][1];
- for (int i = 0; i != LaneSize; ++i) {
+ for (int i = 0; i != NumLaneElts; ++i) {
int M = -1;
if (Src >= 0)
- M = Src * LaneSize + i;
- NewMask[Lane * LaneSize + i] = M;
+ M = Src * NumLaneElts + i;
+ NewMask[Lane * NumLaneElts + i] = M;
}
}
SDValue NewV2 = DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
cast<ShuffleVectorSDNode>(NewV2)->getMask() == Mask)
return SDValue();
- for (int i = 0; i != Size; ++i) {
- NewMask[i] = RepeatMask[i % LaneSize];
+ for (int i = 0; i != NumElts; ++i) {
+ NewMask[i] = RepeatMask[i % NumLaneElts];
if (NewMask[i] < 0)
continue;
- NewMask[i] += (i / LaneSize) * LaneSize;
+ NewMask[i] += (i / NumLaneElts) * NumLaneElts;
}
return DAG.getVectorShuffle(VT, DL, NewV1, NewV2, NewMask);
}