[LLVMdev] Switch instruction lowering

Hans Wennborg hans at chromium.org
Tue Oct 28 17:52:38 PDT 2014


On Mon, Oct 27, 2014 at 2:54 AM, Paweł Bylica <chfast at gmail.com> wrote:
> Hi,
>
> I'm interested in any information about implementations of switch
> instruction and its runtime cost. If it's very target dependent, I'm mostly
> care about X86. Pointing some LLVM code is also good.

I don't think there's any documentation besides the comments in the
code, but switch lowering (to binary tree or jump table, etc.) happens
in SelectionDAGBuilder::visitSwitch()

For switches which are used to select from a set of constant values,
SimplifyCFG will attempt to build a lookup table.

 - Hans




More information about the llvm-dev mailing list