[LLVMdev] Instruction Cost
Hal Finkel
hfinkel at anl.gov
Wed Jan 14 16:08:54 PST 2015
----- Original Message -----
> From: "Jingyue Wu" <jingyue at google.com>
> To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
> Sent: Wednesday, January 14, 2015 5:54:26 PM
> Subject: [LLVMdev] Instruction Cost
>
> Hi,
>
> I'm looking for APIs that compute instruction costs, and noticed
> several of them.
...
>
> So, what's the recommended way to compute instruction costs?
It depends on how you intend to use them.
> 1. A series of APIs of TargetTransformInfo that compute the cost of
> instructions of a particular type (e.g. getArithmeticInstrCost and
> getShuffleCost)
These are used by the vectorizers, and roughly, return costs in reciprocal throughput (the higher the throughput the lower the cost).
>
> 2. TargetTransformInfo::getOperationCost
This is used by TTI::getUserCost, and it intended to provide a cost appropriate for balancing size and performance (it is used by the inliner's cost model, etc.).
> 3. CostModel::getInstructionCost::getInstructionCost in
> lib/Analysis/CostModel.cpp
This is a wrapper around the interfaces in class (1) (getArithmeticInstrCost, etc.) and may or may not be useful for any particular use case. This is used primarily to construct regression tests for the cost models.
>
>
> Only the first one is used extensively in LLVM's code base, but the
> second and third one seems more recently added and more general,
> making me think if they are designed to replace the first approach.
Hopefully this makes things clearer ;)
-Hal
>
>
>
> Thanks,
> Jingyue
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-dev
mailing list