[LLVMdev] Instruction Cost

Hal Finkel hfinkel at anl.gov
Wed Jan 14 16:17:46 PST 2015


----- Original Message -----
> From: "Jingyue Wu" <jingyue at google.com>
> To: "Chandler Carruth" <chandlerc at google.com>
> Cc: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
> Sent: Wednesday, January 14, 2015 6:09:10 PM
> Subject: Re: [LLVMdev] Instruction Cost
> 
> 
> 
> CostModule::getInstructionCost also consults TTI (
> http://llvm.org/docs/doxygen/html/CostModel_8cpp_source.html#l00380
> ). No?

Yes, and is used to create regressions tests for (1). We should also extend it to make creating regression tests for the things in (2) easier, but no one has done that yet (those costs are also much less well tuned).

 -Hal

> 
> 
> Jingyue
> 
> 
> On Wed, Jan 14, 2015 at 4:05 PM, Chandler Carruth <
> chandlerc at google.com > wrote:
> 
> 
> 
> 
> 
> 
> 
> 
> On Wed, Jan 14, 2015 at 3:54 PM, Jingyue Wu < jingyue at google.com >
> wrote:
> 
> 
> 
> I'm looking for APIs that compute instruction costs, and noticed
> several of them.
> 
> 
> 1. A series of APIs of TargetTransformInfo that compute the cost of
> instructions of a particular type (e.g. getArithmeticInstrCost and
> getShuffleCost)
> 
> 2. TargetTransformInfo::getOperationCost
> 3. CostModel::getInstructionCost::getInstructionCost in
> lib/Analysis/CostModel.cpp
> 
> 
> 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.
> 
> 
> So, what's the recommended way to compute instruction costs?
> It depends on what for...
> 
> 
> #3 above is a *very* coarse, but target independent heuristic. It's
> used for basic things that don't need a lot of detail at all.
> 
> 
> #1 and #2 are both in TTI and useful to target-specific IR transforms
> such as the vectorizers and the partial unroller. I would expect #2
> to be implemented in terms of #1 and generally just a wrapper that
> provides a generic interface.
> 
> _______________________________________________
> 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