SLPVectorizer: Take credit for free extractelement instructions

Extract element instructions that will be removed when vectorzing lower the
cost.

Patch by Arch D. Robison!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205020 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Arnold Schwaighofer
2014-03-28 17:21:32 +00:00
parent aa0a2a35f8
commit ce36237826
2 changed files with 36 additions and 2 deletions

View File

@ -1015,8 +1015,17 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
return 0;
}
case Instruction::ExtractElement: {
if (CanReuseExtract(VL))
return 0;
if (CanReuseExtract(VL)) {
int DeadCost = 0;
for (unsigned i = 0, e = VL.size(); i < e; ++i) {
ExtractElementInst *E = cast<ExtractElementInst>(VL[i]);
if (E->hasOneUse())
// Take credit for instruction that will become dead.
DeadCost +=
TTI->getVectorInstrCost(Instruction::ExtractElement, VecTy, i);
}
return -DeadCost;
}
return getGatherCost(VecTy);
}
case Instruction::ZExt: