diff options
author | Karthik Bhat <kv.bhat@samsung.com> | 2014-06-20 04:32:48 +0000 |
---|---|---|
committer | Karthik Bhat <kv.bhat@samsung.com> | 2014-06-20 04:32:48 +0000 |
commit | e03a25da70c6fd476d9be766eba0e46c9f3c1796 (patch) | |
tree | 17758b552280556426b0a83160112b11ef9c3829 /llvm/lib/Target/X86 | |
parent | e1552f664861d9f60c21125f3ca042847c3d1b4a (diff) | |
download | bcm5719-llvm-e03a25da70c6fd476d9be766eba0e46c9f3c1796.tar.gz bcm5719-llvm-e03a25da70c6fd476d9be766eba0e46c9f3c1796.zip |
Add Support to Recognize and Vectorize NON SIMD instructions in SLPVectorizer.
This patch adds support to recognize patterns such as fadd,fsub,fadd,fsub.../add,sub,add,sub... and
vectorizes them as vector shuffles if they are profitable.
These patterns of vector shuffle can later be converted to instructions such as addsubpd etc on X86.
Thanks to Arnold and Hal for the reviews. http://reviews.llvm.org/D4015
llvm-svn: 211339
Diffstat (limited to 'llvm/lib/Target/X86')
-rw-r--r-- | llvm/lib/Target/X86/X86TargetTransformInfo.cpp | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index 299f9a581b8..9fa911967e7 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -402,17 +402,47 @@ unsigned X86TTI::getArithmeticInstrCost(unsigned Opcode, Type *Ty, unsigned X86TTI::getShuffleCost(ShuffleKind Kind, Type *Tp, int Index, Type *SubTp) const { - // We only estimate the cost of reverse shuffles. - if (Kind != SK_Reverse) + // We only estimate the cost of reverse and alternate shuffles. + if (Kind != SK_Reverse && Kind != SK_Alternate) return TargetTransformInfo::getShuffleCost(Kind, Tp, Index, SubTp); - std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Tp); - unsigned Cost = 1; - if (LT.second.getSizeInBits() > 128) - Cost = 3; // Extract + insert + copy. + if (Kind == SK_Reverse) { + std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Tp); + unsigned Cost = 1; + if (LT.second.getSizeInBits() > 128) + Cost = 3; // Extract + insert + copy. - // Multiple by the number of parts. - return Cost * LT.first; + // Multiple by the number of parts. + return Cost * LT.first; + } + + if (Kind == SK_Alternate) { + static const CostTblEntry<MVT::SimpleValueType> X86AltShuffleTbl[] = { + // Alt shuffle cost table for X86. Cost is the number of instructions + // required to create the shuffled vector. + + {ISD::VECTOR_SHUFFLE, MVT::v2f32, 1}, + {ISD::VECTOR_SHUFFLE, MVT::v2i64, 1}, + {ISD::VECTOR_SHUFFLE, MVT::v2f64, 1}, + + {ISD::VECTOR_SHUFFLE, MVT::v2i32, 2}, + {ISD::VECTOR_SHUFFLE, MVT::v4i32, 2}, + {ISD::VECTOR_SHUFFLE, MVT::v4f32, 2}, + + {ISD::VECTOR_SHUFFLE, MVT::v4i16, 8}, + {ISD::VECTOR_SHUFFLE, MVT::v8i16, 8}, + + {ISD::VECTOR_SHUFFLE, MVT::v16i8, 49}}; + + std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Tp); + + int Idx = CostTableLookup(X86AltShuffleTbl, ISD::VECTOR_SHUFFLE, LT.second); + if (Idx == -1) + return TargetTransformInfo::getShuffleCost(Kind, Tp, Index, SubTp); + return LT.first * X86AltShuffleTbl[Idx].Cost; + } + + return TargetTransformInfo::getShuffleCost(Kind, Tp, Index, SubTp); } unsigned X86TTI::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src) const { |