[TTI/CostModel] improve TTI::getGEPCost and use it in CostModel::getInstructionCost
authorJingyue Wu <jingyue@google.com>
Sun, 26 Jul 2015 17:28:13 +0000 (17:28 +0000)
committerJingyue Wu <jingyue@google.com>
Sun, 26 Jul 2015 17:28:13 +0000 (17:28 +0000)
commit9f141640b58bef4eb157e92315c4720f6c513862
treeadbad4dffa983827a6333c6239388746dc92403c
parent47e6b7c3c71ac2a8fbfbc680c04d807ac3d96a54
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243250 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/TargetTransformInfo.h
include/llvm/Analysis/TargetTransformInfoImpl.h
include/llvm/IR/GetElementPtrTypeIterator.h
lib/Analysis/CostModel.cpp
lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
test/Analysis/CostModel/ARM/gep.ll
test/Analysis/CostModel/no_info.ll
test/Transforms/LoopUnroll/X86/partial.ll
test/Transforms/LoopVectorize/X86/metadata-enable.ll