diff options
author | Evgeny Astigeevich <evgeny.astigeevich@arm.com> | 2017-07-27 12:49:27 +0000 |
---|---|---|
committer | Evgeny Astigeevich <evgeny.astigeevich@arm.com> | 2017-07-27 12:49:27 +0000 |
commit | 61c1bd5abcc6f6c20ec9835f96aa2500452b16e5 (patch) | |
tree | fce16f762de54d63675acd305eab38df02b07fd3 /llvm/lib | |
parent | cbbbfe403348379d77a25a20297d8c0bfec2a407 (diff) | |
download | bcm5719-llvm-61c1bd5abcc6f6c20ec9835f96aa2500452b16e5.tar.gz bcm5719-llvm-61c1bd5abcc6f6c20ec9835f96aa2500452b16e5.zip |
[InlineCost, NFC] Change CallAnalyzer::isGEPFree to use TTI::getUserCost instead of TTI::getGEPCost
Currently CallAnalyzer::isGEPFree uses TTI::getGEPCost to check if GEP is free.
TTI::getGEPCost cannot handle cases when GEPs participate in Def-Use dependencies
(see https://reviews.llvm.org/D31186 for example).
There is TTI::getUserCost which can calculate the cost more accurately by
taking dependencies into account.
Differential Revision: https://reviews.llvm.org/D33685
llvm-svn: 309268
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 35693666aa0..8be2ee7881a 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -348,15 +348,14 @@ bool CallAnalyzer::accumulateGEPOffset(GEPOperator &GEP, APInt &Offset) { /// /// Respects any simplified values known during the analysis of this callsite. bool CallAnalyzer::isGEPFree(GetElementPtrInst &GEP) { - SmallVector<Value *, 4> Indices; + SmallVector<Value *, 4> Operands; + Operands.push_back(GEP.getOperand(0)); for (User::op_iterator I = GEP.idx_begin(), E = GEP.idx_end(); I != E; ++I) if (Constant *SimpleOp = SimplifiedValues.lookup(*I)) - Indices.push_back(SimpleOp); + Operands.push_back(SimpleOp); else - Indices.push_back(*I); - return TargetTransformInfo::TCC_Free == - TTI.getGEPCost(GEP.getSourceElementType(), GEP.getPointerOperand(), - Indices); + Operands.push_back(*I); + return TargetTransformInfo::TCC_Free == TTI.getUserCost(&GEP, Operands); } bool CallAnalyzer::visitAlloca(AllocaInst &I) { |