]> git.lizzy.rs Git - rust.git/commit
[MIR trans] Optimize trans for biased switches
authorBjörn Steinbrink <bsteinbr@gmail.com>
Wed, 11 May 2016 19:31:19 +0000 (21:31 +0200)
committerBjörn Steinbrink <bsteinbr@gmail.com>
Wed, 11 May 2016 20:18:46 +0000 (22:18 +0200)
commit49b2cdf47c983d5ea8a576346d08120f0e3af30a
tree73ae95a59ee5eb635975a2f73059eec8f3ca27fe
parentc0495417416c8e0687bc6a997507c403627f6568
[MIR trans] Optimize trans for biased switches

Currently, all switches in MIR are exhausitive, meaning that we can have
a lot of arms that all go to the same basic block, the extreme case
being an if-let expression which results in just 2 possible cases, be
might end up with hundreds of arms for large enums.

To improve this situation and give LLVM less code to chew on, we can
detect whether there's a pre-dominant target basic block in a switch
and then promote this to be the default target, not translating the
corresponding arms at all.

In combination with #33544 this makes unoptimized MIR trans of
nickel.rs as fast as using old trans and greatly improves the times for
optimized builds, which are only 30-40% slower instead of ~300%.

cc #33111
src/librustc_trans/mir/block.rs