> > In fact we might want to move switch optimization up to the tree level > > (just because it's way easier to deal with there). Thus, lower switch > > to a mixture of binary tree & jump-tables (possibly using perfect > > hashing). > > Doing the optimisation at the tree-level was exactly my initial idea. > By splitting the switches at the tree-level, before expand_case, would > then allow for expand_case to transform it either to a jump table or > binary tree depending on the situation.
I'd kinda hope that doing the optimization at the tree level means expand_case doesn't have to handle both types. The tree code converts sparse case ranges to explicit conditionals (or a switch on a compact perfect hash), so anything left to RTL expansion must be a jump table. Paul