[PATCH] D33685: [InlineCost] Change CallAnalyzer::isGEPFree to use TTI::getUserCost instead of TTI::getGEPCost
Evgeny Astigeevich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 30 10:42:17 PDT 2017
eastig created this revision.
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:
> int TargetTransformInfo::getUserCost (const User * U) const
> Estimate the cost of a given IR user when lowered.
>
> This can estimate the cost of either a ConstantExpr or Instruction when lowered. It has two primary advantages over the getOperationCost and getGEPCost above, and one significant disadvantage: it can only be used when the IR construct has already been formed.
>
> The advantages are that it can inspect the SSA use graph to reason more accurately about the cost. For example, all-constant-GEPs can often be folded into a load or other instruction, but if they are used in some other context they may not be folded. This routine can distinguish such cases.
>
> The returned cost is defined in terms of TargetCostConstants, see its comments for a detailed explanation of the cost values.
This patch gets CallAnalyzer::isGEPFree to use TTI::getUserCost instead of TTI::getGEPCost.
https://reviews.llvm.org/D33685
Files:
lib/Analysis/InlineCost.cpp
Index: lib/Analysis/InlineCost.cpp
===================================================================
--- lib/Analysis/InlineCost.cpp
+++ lib/Analysis/InlineCost.cpp
@@ -350,9 +350,7 @@
Indices.push_back(SimpleOp);
else
Indices.push_back(*I);
- return TargetTransformInfo::TCC_Free ==
- TTI.getGEPCost(GEP.getSourceElementType(), GEP.getPointerOperand(),
- Indices);
+ return TargetTransformInfo::TCC_Free == TTI.getUserCost(&GEP);
}
bool CallAnalyzer::visitAlloca(AllocaInst &I) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33685.100733.patch
Type: text/x-patch
Size: 542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170530/4678d53c/attachment.bin>
More information about the llvm-commits
mailing list