mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
2e0edc0f28
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? |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |