[PATCH] D14617: alignment info for cost estimation in SLP vectorization
Tong Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 07:45:10 PST 2015
chentong created this revision.
chentong added a reviewer: llvm-commits.
chentong added a subscriber: chentong.
When the cost of load/store is estimated in SLP vectorization, constant "1" was always given to the cost model. This caused over estimate the cost of sequential version in some architectures that care about the alignment (such as PPC). The fix is to add alignment info.
http://reviews.llvm.org/D14617
Files:
lib/Transforms/Vectorize/SLPVectorizer.cpp
Index: lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1616,15 +1616,19 @@
}
case Instruction::Load: {
// Cost of wide load - cost of scalar loads.
+ LoadInst *LoadI = cast<LoadInst> (VL[0]);
int ScalarLdCost = VecTy->getNumElements() *
- TTI->getMemoryOpCost(Instruction::Load, ScalarTy, 1, 0);
+ TTI->getMemoryOpCost(Instruction::Load, ScalarTy,
+ LoadI->getAlignment(), 0);
int VecLdCost = TTI->getMemoryOpCost(Instruction::Load, VecTy, 1, 0);
return VecLdCost - ScalarLdCost;
}
case Instruction::Store: {
// We know that we can merge the stores. Calculate the cost.
+ StoreInst *StoreI = cast<StoreInst>(VL[0]);
int ScalarStCost = VecTy->getNumElements() *
- TTI->getMemoryOpCost(Instruction::Store, ScalarTy, 1, 0);
+ TTI->getMemoryOpCost(Instruction::Store, ScalarTy,
+ StoreI->getAlignment(), 0);
int VecStCost = TTI->getMemoryOpCost(Instruction::Store, VecTy, 1, 0);
return VecStCost - ScalarStCost;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14617.40049.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151112/7156c881/attachment.bin>
More information about the llvm-commits
mailing list