Branch tables are usually described as an efficient way a compiler can implement a switch statement, and that actually seems how GCC and Clang do it (and LLVM even has an opcode just for that).
If a sequence of if statements is used (instead of a switch), GCC doesn't seem to generate a table, but Clang still does.
Given a compiler that turns the code into basic blocks inside a control flow graph in static single assignment form, how would it decide where to generate tables? Is there any research on that? I'm particularly interested in finding an algorithm for lowering consecutive branchings (found on the CFG/SSA form) into a branch table (as Clang seems to do).
(I actually tried looking for any papers about that but didn't find anything.)
Edit: I do understand that the obvious way to do this is to expand the definition of the SSA to include multiple branchings as a primitive (i.e., blocks may branch to an arbitrary number of blocks); I'm wondering if (and how) the tables could be done in a simpler definition, where each basic block may move to at most two other blocks (i.e., only unconditional moves and an if branching).