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. - Paweł -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141027/285f02e5/attachment.html>
On Mon, Oct 27, 2014 at 10:54:12AM +0100, Paweł Bylica 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.`grep -r "switch instruction"` under directory llvm/lib shows a lot of stuff you might have interest. Most of the code related to switch instructions are under subdirectories IR and Transformation/Utils. HTH, chenwj -- Wei-Ren Chen (陳韋任) Homepage: http://people.cs.nctu.edu.tw/~chenwj
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
Some of the early ideas were actually described in http://llvm.org/pubs/2007-05-31-Switch-Lowering.pdf On Wed, Oct 29, 2014 at 3:52 AM, Hans Wennborg <hans at chromium.org> wrote:> 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Some more general information on switch lowering can be found in the paper "A Superoptimizer Analysis of Multiway Branch Code Generation" in https://gcc.gnu.org/wiki/HomePage?action=AttachFile&do=get&target=gcc-2008-proceedings.pdf -- Sean Silva 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. > > - Paweł > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141030/514af6f9/attachment.html>