[PATCH] D11718: [TTI] Fix default costs for interleaved accesses
silviu.baranga at arm.com
silviu.baranga at arm.com
Mon Aug 3 05:43:11 PDT 2015
sbaranga created this revision.
sbaranga added a subscriber: llvm-commits.
Modify the cost calculation function for interleaved accesses
to use the target-specific costs for insert/extract element and
memory operations.
This better models the case where the backend can't match
the interleaved group, and we are forced to use a wide load
and shuffle vectors.
Interleaved accesses are not enabled by default, so this shouldn't
cause a performance change.
http://reviews.llvm.org/D11718
Files:
include/llvm/CodeGen/BasicTTIImpl.h
Index: include/llvm/CodeGen/BasicTTIImpl.h
===================================================================
--- include/llvm/CodeGen/BasicTTIImpl.h
+++ include/llvm/CodeGen/BasicTTIImpl.h
@@ -534,7 +534,8 @@
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) {
@@ -549,18 +550,20 @@
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 {
@@ -575,12 +578,13 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11718.31226.patch
Type: text/x-patch
Size: 2253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150803/226fe806/attachment.bin>
More information about the llvm-commits
mailing list