[PATCH] D31085: [InlineCost] Increase the cost of Switch

Haicheng Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 10 14:18:15 PDT 2017


haicheng added inline comments.


================
Comment at: lib/Analysis/InlineCost.cpp:1006
 
-  // Otherwise, we need to accumulate a cost proportional to the number of
-  // distinct successor blocks. This fan-out in the CFG cannot be represented
-  // for free even if we can represent the core switch as a jumptable that
-  // takes a single instruction.
+  // Otherwise, we assume the most general case where the big swith is lowered
+  // into a balanced binary tree consisting of case clusters, the probability of
----------------
junbuml wrote:
> haicheng wrote:
> > I think we can exit early if the number of cases is too large.
> In SwitchCaseClusterFinder::getEstimatedNumberOfCluster(), we have early exit for a large number of cases. But I guess you mean something else. Can you specify little bit more about the "too large". 
One case needs at least one instruction.  So if cost + numcases * instrcost > threshold, we can exit early.


https://reviews.llvm.org/D31085





More information about the llvm-commits mailing list