forked from OSchip/llvm-project
[X86] lowerShuffleAsLanePermuteAndRepeatedMask - variable renames. NFCI.
Rename some variables to match lowerShuffleAsRepeatedMaskAndLanePermute - prep work toward adding some equivalent sublane functionality. llvm-svn: 373832
This commit is contained in:
parent
68f21b360b
commit
9ecacb0d54
|
@ -14907,26 +14907,26 @@ static SDValue lowerShuffleAsLanePermuteAndRepeatedMask(
|
||||||
if (is128BitLaneRepeatedShuffleMask(VT, Mask))
|
if (is128BitLaneRepeatedShuffleMask(VT, Mask))
|
||||||
return SDValue();
|
return SDValue();
|
||||||
|
|
||||||
int Size = Mask.size();
|
int NumElts = Mask.size();
|
||||||
int NumLanes = VT.getSizeInBits() / 128;
|
int NumLanes = VT.getSizeInBits() / 128;
|
||||||
int LaneSize = 128 / VT.getScalarSizeInBits();
|
int NumLaneElts = 128 / VT.getScalarSizeInBits();
|
||||||
SmallVector<int, 16> RepeatMask(LaneSize, -1);
|
SmallVector<int, 16> RepeatMask(NumLaneElts, -1);
|
||||||
SmallVector<std::array<int, 2>, 2> LaneSrcs(NumLanes, {{-1, -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
|
// First pass will try to fill in the RepeatMask from lanes that need two
|
||||||
// sources.
|
// sources.
|
||||||
for (int Lane = 0; Lane != NumLanes; ++Lane) {
|
for (int Lane = 0; Lane != NumLanes; ++Lane) {
|
||||||
int Srcs[2] = { -1, -1 };
|
int Srcs[2] = {-1, -1};
|
||||||
SmallVector<int, 16> InLaneMask(LaneSize, -1);
|
SmallVector<int, 16> InLaneMask(NumLaneElts, -1);
|
||||||
for (int i = 0; i != LaneSize; ++i) {
|
for (int i = 0; i != NumLaneElts; ++i) {
|
||||||
int M = Mask[(Lane * LaneSize) + i];
|
int M = Mask[(Lane * NumLaneElts) + i];
|
||||||
if (M < 0)
|
if (M < 0)
|
||||||
continue;
|
continue;
|
||||||
// Determine which of the possible input lanes (NumLanes from each source)
|
// Determine which of the possible input lanes (NumLanes from each source)
|
||||||
// this element comes from. Assign that as one of the sources for this
|
// 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
|
// lane. We can assign up to 2 sources for this lane. If we run out
|
||||||
// sources we can't do anything.
|
// sources we can't do anything.
|
||||||
int LaneSrc = M / LaneSize;
|
int LaneSrc = M / NumLaneElts;
|
||||||
int Src;
|
int Src;
|
||||||
if (Srcs[0] < 0 || Srcs[0] == LaneSrc)
|
if (Srcs[0] < 0 || Srcs[0] == LaneSrc)
|
||||||
Src = 0;
|
Src = 0;
|
||||||
|
@ -14936,7 +14936,7 @@ static SDValue lowerShuffleAsLanePermuteAndRepeatedMask(
|
||||||
return SDValue();
|
return SDValue();
|
||||||
|
|
||||||
Srcs[Src] = LaneSrc;
|
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 this lane has two sources, see if it fits with the repeat mask so far.
|
||||||
|
@ -14992,23 +14992,23 @@ static SDValue lowerShuffleAsLanePermuteAndRepeatedMask(
|
||||||
if (LaneSrcs[Lane][0] >= 0)
|
if (LaneSrcs[Lane][0] >= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int i = 0; i != LaneSize; ++i) {
|
for (int i = 0; i != NumLaneElts; ++i) {
|
||||||
int M = Mask[(Lane * LaneSize) + i];
|
int M = Mask[(Lane * NumLaneElts) + i];
|
||||||
if (M < 0)
|
if (M < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If RepeatMask isn't defined yet we can define it ourself.
|
// If RepeatMask isn't defined yet we can define it ourself.
|
||||||
if (RepeatMask[i] < 0)
|
if (RepeatMask[i] < 0)
|
||||||
RepeatMask[i] = M % LaneSize;
|
RepeatMask[i] = M % NumLaneElts;
|
||||||
|
|
||||||
if (RepeatMask[i] < Size) {
|
if (RepeatMask[i] < NumElts) {
|
||||||
if (RepeatMask[i] != M % LaneSize)
|
if (RepeatMask[i] != M % NumLaneElts)
|
||||||
return SDValue();
|
return SDValue();
|
||||||
LaneSrcs[Lane][0] = M / LaneSize;
|
LaneSrcs[Lane][0] = M / NumLaneElts;
|
||||||
} else {
|
} else {
|
||||||
if (RepeatMask[i] != ((M % LaneSize) + Size))
|
if (RepeatMask[i] != ((M % NumLaneElts) + NumElts))
|
||||||
return SDValue();
|
return SDValue();
|
||||||
LaneSrcs[Lane][1] = M / LaneSize;
|
LaneSrcs[Lane][1] = M / NumLaneElts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15016,14 +15016,14 @@ static SDValue lowerShuffleAsLanePermuteAndRepeatedMask(
|
||||||
return SDValue();
|
return SDValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallVector<int, 16> NewMask(Size, -1);
|
SmallVector<int, 16> NewMask(NumElts, -1);
|
||||||
for (int Lane = 0; Lane != NumLanes; ++Lane) {
|
for (int Lane = 0; Lane != NumLanes; ++Lane) {
|
||||||
int Src = LaneSrcs[Lane][0];
|
int Src = LaneSrcs[Lane][0];
|
||||||
for (int i = 0; i != LaneSize; ++i) {
|
for (int i = 0; i != NumLaneElts; ++i) {
|
||||||
int M = -1;
|
int M = -1;
|
||||||
if (Src >= 0)
|
if (Src >= 0)
|
||||||
M = Src * LaneSize + i;
|
M = Src * NumLaneElts + i;
|
||||||
NewMask[Lane * LaneSize + i] = M;
|
NewMask[Lane * NumLaneElts + i] = M;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDValue NewV1 = DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
|
SDValue NewV1 = DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
|
||||||
|
@ -15036,11 +15036,11 @@ static SDValue lowerShuffleAsLanePermuteAndRepeatedMask(
|
||||||
|
|
||||||
for (int Lane = 0; Lane != NumLanes; ++Lane) {
|
for (int Lane = 0; Lane != NumLanes; ++Lane) {
|
||||||
int Src = LaneSrcs[Lane][1];
|
int Src = LaneSrcs[Lane][1];
|
||||||
for (int i = 0; i != LaneSize; ++i) {
|
for (int i = 0; i != NumLaneElts; ++i) {
|
||||||
int M = -1;
|
int M = -1;
|
||||||
if (Src >= 0)
|
if (Src >= 0)
|
||||||
M = Src * LaneSize + i;
|
M = Src * NumLaneElts + i;
|
||||||
NewMask[Lane * LaneSize + i] = M;
|
NewMask[Lane * NumLaneElts + i] = M;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDValue NewV2 = DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
|
SDValue NewV2 = DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
|
||||||
|
@ -15051,12 +15051,12 @@ static SDValue lowerShuffleAsLanePermuteAndRepeatedMask(
|
||||||
cast<ShuffleVectorSDNode>(NewV2)->getMask() == Mask)
|
cast<ShuffleVectorSDNode>(NewV2)->getMask() == Mask)
|
||||||
return SDValue();
|
return SDValue();
|
||||||
|
|
||||||
for (int i = 0; i != Size; ++i) {
|
for (int i = 0; i != NumElts; ++i) {
|
||||||
NewMask[i] = RepeatMask[i % LaneSize];
|
NewMask[i] = RepeatMask[i % NumLaneElts];
|
||||||
if (NewMask[i] < 0)
|
if (NewMask[i] < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
NewMask[i] += (i / LaneSize) * LaneSize;
|
NewMask[i] += (i / NumLaneElts) * NumLaneElts;
|
||||||
}
|
}
|
||||||
return DAG.getVectorShuffle(VT, DL, NewV1, NewV2, NewMask);
|
return DAG.getVectorShuffle(VT, DL, NewV1, NewV2, NewMask);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue