[LLVMdev] Lowering switch statements with PGO

Owen Anderson resistor at mac.com
Mon Dec 15 11:00:18 PST 2014


> On Dec 15, 2014, at 9:57 AM, Chad Rosier <mcrosier at codeaurora.org> wrote:
> 
> 
> The current switch lowering code sorts based on case values and is lowered
> with a combination of binary trees, lookup tables, bit tests and magic. 
> If we lower the switch based on branch probabilities, I think the most
> reasonable approach would be to disable the lookup tables and stick with a
> purely tree structure.  Does anyone object or have opinions on this
> matter?


If one case strongly dominates the others, and there are still a large number of unlikely cases, it seems like it would be a good idea to do a branch for the hot case, and then a lookup table for the cold cases.  More generally, it makes intuitive sense to me that this kind of switch-peeling is naturally recursive, and we should allow the existing heuristics to fire each time we peel out cases.

—Owen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141215/e91b47c3/attachment.html>


More information about the llvm-dev mailing list