[LLVMdev] Lowering switch statements with PGO
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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev