summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/X86/X86TargetTransformInfo.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 960eddca925..b8f6c540d15 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -872,11 +872,19 @@ int X86TTIImpl::getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
if (Kind == TTI::SK_Broadcast)
LT.first = 1;
- // Subvector extractions are free if they start at beginning of the
- // vector.
- if (Kind == TTI::SK_ExtractSubvector && LT.second.isVector() &&
- ((Index % LT.second.getVectorNumElements()) == 0))
- return 0;
+ // Subvector extractions are free if they start at the beginning of a
+ // vector and cheap if the subvectors are aligned.
+ if (Kind == TTI::SK_ExtractSubvector && LT.second.isVector()) {
+ int NumElts = LT.second.getVectorNumElements();
+ if ((Index % NumElts) == 0)
+ return 0;
+ std::pair<int, MVT> SubLT = TLI->getTypeLegalizationCost(DL, SubTp);
+ if (SubLT.second.isVector()) {
+ int NumSubElts = SubLT.second.getVectorNumElements();
+ if ((Index % NumSubElts) == 0 && (NumElts % NumSubElts) == 0)
+ return SubLT.first;
+ }
+ }
// We are going to permute multiple sources and the result will be in multiple
// destinations. Providing an accurate cost only for splits where the element
OpenPOWER on IntegriCloud