summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-04-14 07:22:22 +0000
committerNadav Rotem <nrotem@apple.com>2013-04-14 07:22:22 +0000
commit3403c115290eb294e5528bda5aa4798f6305a196 (patch)
treed83320816bf69c97b37f3f09f25fd50b806b92cf /llvm/lib/Transforms
parent0db0690a70a8d654a974d9d5b24592e39b23870a (diff)
downloadbcm5719-llvm-3403c115290eb294e5528bda5aa4798f6305a196.tar.gz
bcm5719-llvm-3403c115290eb294e5528bda5aa4798f6305a196.zip
SLP: Document the scalarization cost method.
llvm-svn: 179479
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Vectorize/VecUtils.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VecUtils.cpp b/llvm/lib/Transforms/Vectorize/VecUtils.cpp
index 584f3d97788..c85711532dd 100644
--- a/llvm/lib/Transforms/Vectorize/VecUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VecUtils.cpp
@@ -110,6 +110,7 @@ bool BoUpSLP::vectorizeStoreChain(ValueList &Chain, int CostThreshold) {
if (!isPowerOf2_32(Sz) || VF < 2) return false;
bool Changed = false;
+ // Look for profitable vectorizable trees at all offsets, starting at zero.
for (unsigned i = 0, e = Chain.size(); i < e; ++i) {
if (i + VF > e) return Changed;
DEBUG(dbgs()<<"SLP: Analyzing " << VF << " stores at offset "<< i << "\n");
@@ -166,7 +167,10 @@ bool BoUpSLP::vectorizeStores(StoreList &Stores, int costThreshold) {
}
bool Vectorized = vectorizeStoreChain(Operands, costThreshold);
- if (Vectorized) VectorizedStores.insert(Operands.begin(), Operands.end());
+
+ // Mark the vectorized stores so that we don't vectorize them again.
+ if (Vectorized)
+ VectorizedStores.insert(Operands.begin(), Operands.end());
Changed |= Vectorized;
}
@@ -174,12 +178,12 @@ bool BoUpSLP::vectorizeStores(StoreList &Stores, int costThreshold) {
}
int BoUpSLP::getScalarizationCost(ValueList &VL) {
+ // Find the type of the operands in VL.
Type *ScalarTy = VL[0]->getType();
-
if (StoreInst *SI = dyn_cast<StoreInst>(VL[0]))
ScalarTy = SI->getValueOperand()->getType();
-
VectorType *VecTy = VectorType::get(ScalarTy, VL.size());
+ // Find the cost of inserting/extracting values from the vector.
return getScalarizationCost(VecTy);
}
@@ -222,6 +226,9 @@ void BoUpSLP::vectorizeArith(ValueList &Operands) {
Value *Vec = vectorizeTree(Operands, Operands.size());
BasicBlock::iterator Loc = cast<Instruction>(Vec);
IRBuilder<> Builder(++Loc);
+ // After vectorizing the operands we need to generate extractelement
+ // instructions and replace all of the uses of the scalar values with
+ // the values that we extracted from the vectorized tree.
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
Value *S = Builder.CreateExtractElement(Vec, Builder.getInt32(i));
Operands[i]->replaceAllUsesWith(S);
OpenPOWER on IntegriCloud