forked from OSchip/llvm-project
[X86][SSE] lowerVectorShuffleWithUNPCK - use equivalent shuffle mask test.
Use isShuffleEquivalent to match UNPCK shuffles - better support for build vector inputs. llvm-svn: 251207
This commit is contained in:
parent
1eeb2da7d4
commit
fdfed5143c
|
@ -6785,43 +6785,32 @@ static SDValue lowerVectorShuffleWithUNPCK(SDLoc DL, MVT VT, ArrayRef<int> Mask,
|
||||||
SDValue V1, SDValue V2,
|
SDValue V1, SDValue V2,
|
||||||
SelectionDAG &DAG) {
|
SelectionDAG &DAG) {
|
||||||
int NumElts = VT.getVectorNumElements();
|
int NumElts = VT.getVectorNumElements();
|
||||||
bool Unpckl = true;
|
|
||||||
bool Unpckh = true;
|
|
||||||
bool UnpcklSwapped = true;
|
|
||||||
bool UnpckhSwapped = true;
|
|
||||||
int NumEltsInLane = 128 / VT.getScalarSizeInBits();
|
int NumEltsInLane = 128 / VT.getScalarSizeInBits();
|
||||||
|
SmallVector<int, 8> Unpckl;
|
||||||
|
SmallVector<int, 8> Unpckh;
|
||||||
|
|
||||||
for (int i = 0; i < NumElts; ++i) {
|
for (int i = 0; i < NumElts; ++i) {
|
||||||
unsigned LaneStart = (i / NumEltsInLane) * NumEltsInLane;
|
unsigned LaneStart = (i / NumEltsInLane) * NumEltsInLane;
|
||||||
|
|
||||||
int LoPos = (i % NumEltsInLane) / 2 + LaneStart + NumElts * (i % 2);
|
int LoPos = (i % NumEltsInLane) / 2 + LaneStart + NumElts * (i % 2);
|
||||||
int HiPos = LoPos + NumEltsInLane / 2;
|
int HiPos = LoPos + NumEltsInLane / 2;
|
||||||
int LoPosSwapped = (LoPos + NumElts) % (NumElts * 2);
|
Unpckl.push_back(LoPos);
|
||||||
int HiPosSwapped = (HiPos + NumElts) % (NumElts * 2);
|
Unpckh.push_back(HiPos);
|
||||||
|
|
||||||
if (Mask[i] == -1)
|
|
||||||
continue;
|
|
||||||
if (Mask[i] != LoPos)
|
|
||||||
Unpckl = false;
|
|
||||||
if (Mask[i] != HiPos)
|
|
||||||
Unpckh = false;
|
|
||||||
if (Mask[i] != LoPosSwapped)
|
|
||||||
UnpcklSwapped = false;
|
|
||||||
if (Mask[i] != HiPosSwapped)
|
|
||||||
UnpckhSwapped = false;
|
|
||||||
if (!Unpckl && !Unpckh && !UnpcklSwapped && !UnpckhSwapped)
|
|
||||||
return SDValue();
|
|
||||||
}
|
}
|
||||||
if (Unpckl)
|
|
||||||
|
if (isShuffleEquivalent(V1, V2, Mask, Unpckl))
|
||||||
return DAG.getNode(X86ISD::UNPCKL, DL, VT, V1, V2);
|
return DAG.getNode(X86ISD::UNPCKL, DL, VT, V1, V2);
|
||||||
if (Unpckh)
|
if (isShuffleEquivalent(V1, V2, Mask, Unpckh))
|
||||||
return DAG.getNode(X86ISD::UNPCKH, DL, VT, V1, V2);
|
return DAG.getNode(X86ISD::UNPCKH, DL, VT, V1, V2);
|
||||||
if (UnpcklSwapped)
|
|
||||||
|
// Commute and try again.
|
||||||
|
ShuffleVectorSDNode::commuteMask(Unpckl);
|
||||||
|
if (isShuffleEquivalent(V1, V2, Mask, Unpckl))
|
||||||
return DAG.getNode(X86ISD::UNPCKL, DL, VT, V2, V1);
|
return DAG.getNode(X86ISD::UNPCKL, DL, VT, V2, V1);
|
||||||
if (UnpckhSwapped)
|
|
||||||
|
ShuffleVectorSDNode::commuteMask(Unpckh);
|
||||||
|
if (isShuffleEquivalent(V1, V2, Mask, Unpckh))
|
||||||
return DAG.getNode(X86ISD::UNPCKH, DL, VT, V2, V1);
|
return DAG.getNode(X86ISD::UNPCKH, DL, VT, V2, V1);
|
||||||
|
|
||||||
llvm_unreachable("Unexpected result of UNPCK mask analysis");
|
|
||||||
return SDValue();
|
return SDValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue