diff options
| author | bors <bors@rust-lang.org> | 2020-09-20 17:54:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-20 17:54:44 +0000 |
| commit | 2e0edc0f28c5647141bedba02e7a222d3a5dc9c3 (patch) | |
| tree | 8c6c0ef494292f83366eccc7cb4b639b73013112 /compiler/rustc_codegen_llvm/src | |
| parent | 81e02708f1f4760244756548981277d5199baa9a (diff) | |
| parent | 0363694c7ff72d0a4b1c52ebf2320930c3b60da8 (diff) | |
| download | rust-2e0edc0f28c5647141bedba02e7a222d3a5dc9c3.tar.gz rust-2e0edc0f28c5647141bedba02e7a222d3a5dc9c3.zip | |
Auto merge of #75119 - simonvandel:early-otherwise, r=oli-obk
New MIR optimization pass to reduce branches on match of tuples of enums
Fixes #68867 by adding a new pass that turns something like
```rust
let x: Option<()>;
let y: Option<()>;
match (x,y) {
(Some(_), Some(_)) => {0},
_ => {1}
}
```
into something like
```rust
let x: Option<()>;
let y: Option<()>;
let discriminant_x = // get discriminant of x
let discriminant_y = // get discriminant of x
if discriminant_x != discriminant_y {1} else {0}
```
The opt-diffs still have the old basic blocks like
```
bb3: {
_8 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:21:21: 21:30
switchInt(move _8) -> [1_isize: bb7, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:21:21: 21:30
}
bb4: {
_9 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:22:23: 22:34
switchInt(move _9) -> [2_isize: bb8, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:22:23: 22:34
}
bb5: {
_10 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early-otherwise-branch-68867.rs:23:23: 23:34
switchInt(move _10) -> [3_isize: bb9, otherwise: bb2]; // scope 0 at $DIR/early-otherwise-branch-68867.rs:23:23: 23:34
}
```
These do get removed on later passes. I'm not sure if I should include those passes in the test to make it clear?
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
