[PATCH] D37170: [TargetTransformInfo] Add a new public interface getInstructionCost

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 15:42:09 PDT 2017


Carrot added inline comments.


================
Comment at: include/llvm/Analysis/TargetTransformInfo.h:127
+    case TCK_Throughput:
+      return getUserCost(I);
+
----------------
hfinkel wrote:
> This is good, but this is the wrong function. getUserCost is what the inliner uses, and could be viewed as returning normalized code size (right now), not throughput.
> 
> If we want to have a single interface like this for throughput, which just takes an arbitrary instruction, then we can, but we need to pull the code out of CostModelAnalysis::getInstructionCost (in lib/Analysis/CostModel.cpp). I'd be highly supportive of doing this (currently that code lives in the analysis pass because that's how we test the code-model interface, but it's not otherwise reusable, and that's not great).
> 
> Then we need to decide how to integrate everything. One option is to add this `TargetCostKind kind` parameter to the existing throughput cost-model interface. Another option is to only have this parameter on this generic function taking an Instruction* and leave everything else alone. Or we leave all of this alone and just add new interfaces for now providing latency and size (which we do by renaming the 'user cost' function).
Thank you for the good suggestion.

I moved the code from CostModelAnalysis::getInstructionCost to TargetTransformInfo::getInstructionThroughput.

I chose the following interface function.
int getInstructionCost(const Instruction *I, enum TargetCostKind kind).


https://reviews.llvm.org/D37170





More information about the llvm-commits mailing list