VectorType *SubVT = VectorType::get(VT->getElementType(), NumSubElts);
// Firstly, the cost of load/store operation.
- unsigned Cost = getMemoryOpCost(Opcode, VecTy, Alignment, AddressSpace);
+ unsigned Cost = static_cast<T *>(this)->getMemoryOpCost(
+ Opcode, VecTy, Alignment, AddressSpace);
// Then plus the cost of interleave operation.
if (Opcode == Instruction::Load) {
assert(Indices.size() <= Factor &&
"Interleaved memory op has too many members");
+
for (unsigned Index : Indices) {
assert(Index < Factor && "Invalid index for interleaved memory op");
// Extract elements from loaded vector for each sub vector.
for (unsigned i = 0; i < NumSubElts; i++)
- Cost += getVectorInstrCost(Instruction::ExtractElement, VT,
- Index + i * Factor);
+ Cost += static_cast<T *>(this)->getVectorInstrCost(
+ Instruction::ExtractElement, VT, Index + i * Factor);
}
unsigned InsSubCost = 0;
for (unsigned i = 0; i < NumSubElts; i++)
- InsSubCost += getVectorInstrCost(Instruction::InsertElement, SubVT, i);
+ InsSubCost += static_cast<T *>(this)->getVectorInstrCost(
+ Instruction::InsertElement, SubVT, i);
Cost += Indices.size() * InsSubCost;
} else {
unsigned ExtSubCost = 0;
for (unsigned i = 0; i < NumSubElts; i++)
- ExtSubCost += getVectorInstrCost(Instruction::ExtractElement, SubVT, i);
-
- Cost += Factor * ExtSubCost;
+ ExtSubCost += static_cast<T *>(this)->getVectorInstrCost(
+ Instruction::ExtractElement, SubVT, i);
+ Cost += ExtSubCost * Factor;
for (unsigned i = 0; i < NumElts; i++)
- Cost += getVectorInstrCost(Instruction::InsertElement, VT, i);
+ Cost += static_cast<T *>(this)
+ ->getVectorInstrCost(Instruction::InsertElement, VT, i);
}
return Cost;