Skip to content

Commit

Permalink
[SLP] Optimize getSpillCost(); NFCI
Browse files Browse the repository at this point in the history
For a given set of live values, the spill cost will always be the
same for each call. Compute the cost once and multiply it by the
number of calls.

(I'm not sure this spill cost modeling makes sense if there are
multiple calls, as the spill cost will likely be shared across
calls in that case. But that's how it currently works.)

llvm-svn: 365552
  • Loading branch information
nikic committed Jul 9, 2019
1 parent 1366262 commit 5ca39e8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3355,6 +3355,7 @@ int BoUpSLP::getSpillCost() const {
});

// Now find the sequence of instructions between PrevInst and Inst.
unsigned NumCalls = 0;
BasicBlock::reverse_iterator InstIt = ++Inst->getIterator().getReverse(),
PrevInstIt =
PrevInst->getIterator().getReverse();
Expand All @@ -3367,16 +3368,19 @@ int BoUpSLP::getSpillCost() const {
// Debug informations don't impact spill cost.
if ((isa<CallInst>(&*PrevInstIt) &&
!isa<DbgInfoIntrinsic>(&*PrevInstIt)) &&
&*PrevInstIt != PrevInst) {
SmallVector<Type*, 4> V;
for (auto *II : LiveValues)
V.push_back(VectorType::get(II->getType(), BundleWidth));
Cost += TTI->getCostOfKeepingLiveOverCall(V);
}
&*PrevInstIt != PrevInst)
NumCalls++;

++PrevInstIt;
}

if (NumCalls) {
SmallVector<Type*, 4> V;
for (auto *II : LiveValues)
V.push_back(VectorType::get(II->getType(), BundleWidth));
Cost += NumCalls * TTI->getCostOfKeepingLiveOverCall(V);
}

PrevInst = Inst;
}

Expand Down

0 comments on commit 5ca39e8

Please sign in to comment.