The cost of splitting a large vector instruction is not being taken into account by the getUserCost function. This was leading to some loops being over unrolled. The cost of a vector instruction is now being multiplied by the cost of the type legalization. This will return a more accurate cost.
Committing on behalf on Brad Nemanich (brad.nemanich@ibm.com)
Differential Revision: https://reviews.llvm.org/D38961
llvm-svn: 316174
diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
index d3295a9..52c5b68 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
@@ -189,6 +189,17 @@
return PPCTTIImpl::getIntImmCost(Imm, Ty);
}
+unsigned PPCTTIImpl::getUserCost(const User *U,
+ ArrayRef<const Value *> Operands) {
+ if (U->getType()->isVectorTy()) {
+ // Instructions that need to be split should cost more.
+ std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, U->getType());
+ return LT.first * BaseT::getUserCost(U, Operands);
+ }
+
+ return BaseT::getUserCost(U, Operands);
+}
+
void PPCTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
TTI::UnrollingPreferences &UP) {
if (ST->getDarwinDirective() == PPC::DIR_A2) {