<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 14, 2015 at 3:54 PM, Jingyue Wu <span dir="ltr"><<a href="mailto:jingyue@google.com" target="_blank">jingyue@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm looking for APIs that compute instruction costs, and noticed several of them. <div><br></div><div>1. A series of APIs of TargetTransformInfo that compute the cost of instructions of a particular type (e.g. getArithmeticInstrCost and getShuffleCost)<br></div><div>2. TargetTransformInfo::getOperationCost</div><div>3. CostModel::getInstructionCost::getInstructionCost in lib/Analysis/CostModel.cpp</div><div><br></div><div>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.</div><div><br></div><div>So, what's the recommended way to compute instruction costs? </div></div></blockquote></div><br>It depends on what for...</div><div class="gmail_extra"><br></div><div class="gmail_extra">#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.</div><div class="gmail_extra"><br></div><div class="gmail_extra">#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.</div></div>