Maybe you want to catch up on the topics of pipelined CPUs,
out-of-order execution and the impact of branch misprediction
penalties. Writing a good compiler for a modern CPU is not easy.
Many design decisions that may have been right two decades ago,
no longer apply.
Sure. I wasn't saying my design is correct for modern CPUs. Just that a 2-decade old compuler was taking some care over switch table compilation, so I would expect modern compilers to do this too and aim for something that matched the capabilities and issues of modern CPUs. Hence the comment about the state of the art having advanced...
To get this back on topic: incidentally trace compilers (such as
LuaJIT) generate these kind of decision trees on-the-fly, based on
runtime execution statistics.
Indeed. A static compiler would need to guess frequency and would proably guess wrong. You get the advantage of using the facts :)