about summary refs log tree commit diff
path: root/src/test/codegen/match.rs
AgeCommit message (Collapse)AuthorLines
2019-02-21Fix codegen testMatthew Jasper-2/+2
2018-12-25Remove licensesMark Rousskov-10/+0
2018-02-20rustc_mir: always run the deaggregator.Eduard-Mihai Burtescu-3/+3
2017-11-14always add an unreachable branch on matches to give more info to llvm about ↵Djzin-3/+6
which values are possible
2017-02-10Rebase fixupsSimonas Kazlauskas-1/+1
2017-02-10Fix codegen testSimonas Kazlauskas-3/+7
2015-09-25Tell LLVM when a match is exhaustiveBjörn Steinbrink-0/+30
By putting an "unreachable" instruction into the default arm of a switch instruction we can let LLVM know that the match is exhaustive, allowing for better optimizations. For example, this match: ```rust pub enum Enum { One, Two, Three, } impl Enum { pub fn get_disc(self) -> u8 { match self { Enum::One => 0, Enum::Two => 1, Enum::Three => 2, } } } ``` Currently compiles to this on x86_64: ```asm .cfi_startproc movzbl %dil, %ecx cmpl $1, %ecx setne %al testb %cl, %cl je .LBB0_2 incb %al movb %al, %dil .LBB0_2: movb %dil, %al retq .Lfunc_end0: ``` But with this change we get: ```asm .cfi_startproc movb %dil, %al retq .Lfunc_end0: ```