});
// Now find the sequence of instructions between PrevInst and Inst.
+ unsigned NumCalls = 0;
BasicBlock::reverse_iterator InstIt = ++Inst->getIterator().getReverse(),
PrevInstIt =
PrevInst->getIterator().getReverse();
// 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;
}