summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/CostModel.cpp
diff options
context:
space:
mode:
authorJingyue Wu <jingyue@google.com>2015-07-26 17:28:13 +0000
committerJingyue Wu <jingyue@google.com>2015-07-26 17:28:13 +0000
commitbf485f059cccef6b6ff90aa23ad8523688c8b189 (patch)
tree8635080289cfb57d50ed2efb210e0e50c6d060bd /llvm/lib/Analysis/CostModel.cpp
parent65d35a14b7d28aa3462af83d391a5039cc52a842 (diff)
downloadbcm5719-llvm-bf485f059cccef6b6ff90aa23ad8523688c8b189.tar.gz
bcm5719-llvm-bf485f059cccef6b6ff90aa23ad8523688c8b189.zip
[TTI/CostModel] improve TTI::getGEPCost and use it in CostModel::getInstructionCost
Summary: This patch updates TargetTransformInfoImplCRTPBase::getGEPCost to consider addressing modes. It now returns TCC_Free when the GEP can be completely folded to an addresing mode. I started this patch as I refactored SLSR. Function isGEPFoldable looks common and is indeed used by some WIP of mine. So I extracted that logic to getGEPCost. Furthermore, I noticed getGEPCost wasn't directly tested anywhere. The best testing bed seems CostModel, but its getInstructionCost method invokes getAddressComputationCost for GEPs which provides very coarse estimation. So this patch also makes getInstructionCost call the updated getGEPCost for GEPs. This change inevitably breaks some tests because the cost model changes, but nothing looks seriously wrong -- if we believe the new cost model is the right way to go, these tests should be updated. This patch is not perfect yet -- the comments in some tests need to be updated. I want to know whether this is a right approach before fixing those details. Reviewers: chandlerc, hfinkel Subscribers: aschwaighofer, llvm-commits, aemerson Differential Revision: http://reviews.llvm.org/D9819 llvm-svn: 243250
Diffstat (limited to 'llvm/lib/Analysis/CostModel.cpp')
-rw-r--r--llvm/lib/Analysis/CostModel.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/CostModel.cpp b/llvm/lib/Analysis/CostModel.cpp
index b529c1a70aa..da790d74524 100644
--- a/llvm/lib/Analysis/CostModel.cpp
+++ b/llvm/lib/Analysis/CostModel.cpp
@@ -383,10 +383,8 @@ unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
return -1;
switch (I->getOpcode()) {
- case Instruction::GetElementPtr:{
- Type *ValTy = I->getOperand(0)->getType()->getPointerElementType();
- return TTI->getAddressComputationCost(ValTy);
- }
+ case Instruction::GetElementPtr:
+ return TTI->getUserCost(I);
case Instruction::Ret:
case Instruction::PHI:
OpenPOWER on IntegriCloud