SLP Vectorizer: Extract cost will only be added once even if the scalar has multiple external uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195406 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Yi Jiang
2013-11-22 01:57:02 +00:00
parent ef70984795
commit 709a31b5f9
2 changed files with 34 additions and 0 deletions

View File

@ -1082,9 +1082,13 @@ int BoUpSLP::getTreeCost() {
Cost += C;
}
SmallSet<Value *, 16> ExtractCostCalculated;
int ExtractCost = 0;
for (UserList::iterator I = ExternalUses.begin(), E = ExternalUses.end();
I != E; ++I) {
// We only add extract cost once for the same scalar.
if (!ExtractCostCalculated.insert(I->Scalar))
continue;
VectorType *VecTy = VectorType::get(I->Scalar->getType(), BundleWidth);
ExtractCost += TTI->getVectorInstrCost(Instruction::ExtractElement, VecTy,