summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86ISelLowering.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2017-07-06 12:22:58 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2017-07-06 12:22:58 +0000
commitcc0f785dcab367ad737e99ff12da5b79846b48eb (patch)
tree801365fb12d052112b8c9705f761c8254f29be56 /llvm/lib/Target/X86/X86ISelLowering.cpp
parent21fb07b7157311fd2625805d83a3b23689e554fe (diff)
downloadbcm5719-llvm-cc0f785dcab367ad737e99ff12da5b79846b48eb.tar.gz
bcm5719-llvm-cc0f785dcab367ad737e99ff12da5b79846b48eb.zip
[X86][SSE4A] Add support for shuffle combining to EXTRQ.
llvm-svn: 307254
Diffstat (limited to 'llvm/lib/Target/X86/X86ISelLowering.cpp')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index f1269822463..02c8ec4d8f7 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -9364,7 +9364,7 @@ static bool matchVectorShuffleAsEXTRQ(MVT VT, SDValue &V1, SDValue &V2,
int Idx = -1;
for (int i = 0; i != Len; ++i) {
int M = Mask[i];
- if (M < 0)
+ if (M == SM_SentinelUndef)
continue;
SDValue &V = (M < Size ? V1 : V2);
M = M % Size;
@@ -27696,6 +27696,33 @@ static bool combineX86ShuffleChain(ArrayRef<SDValue> Inputs, SDValue Root,
return true;
}
+ // Annoyingly, SSE4A instructions don't map into the above match helpers.
+ if (Subtarget.hasSSE4A() && AllowIntDomain && RootSizeInBits == 128) {
+ ShuffleVT = MVT::getIntegerVT(MaskEltSizeInBits);
+ ShuffleVT = MVT::getVectorVT(ShuffleVT, NumMaskElts);
+
+ APInt Zeroable(NumMaskElts, 0);
+ for (unsigned i = 0; i != NumMaskElts; ++i)
+ if (isUndefOrZero(Mask[i]))
+ Zeroable.setBit(i);
+
+ uint64_t BitLen, BitIdx;
+ if (matchVectorShuffleAsEXTRQ(ShuffleVT, V1, V2, Mask, BitLen, BitIdx,
+ Zeroable)) {
+ if (Depth == 1 && Root.getOpcode() == X86ISD::EXTRQI)
+ return false; // Nothing to do!
+ V1 = DAG.getBitcast(ShuffleVT, V1);
+ DCI.AddToWorklist(V1.getNode());
+ Res = DAG.getNode(X86ISD::EXTRQI, DL, ShuffleVT, V1,
+ DAG.getConstant(BitLen, DL, MVT::i8),
+ DAG.getConstant(BitIdx, DL, MVT::i8));
+ DCI.AddToWorklist(Res.getNode());
+ DCI.CombineTo(Root.getNode(), DAG.getBitcast(RootVT, Res),
+ /*AddTo*/ true);
+ return true;
+ }
+ }
+
// Don't try to re-form single instruction chains under any circumstances now
// that we've done encoding canonicalization for them.
if (Depth < 2)
OpenPOWER on IntegriCloud