-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #112001 - saethlin:enable-matchbranchsimplification, r=…
…cjgillot Enable MatchBranchSimplification This pass is one of the small number of benefits from `-Zmir-opt-level=3` that has motivated rustc_codegen_cranelift to use it: https://github.com/rust-lang/rust/blob/19ed0aade60e1c1038fe40554bcd9d01b717effa/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs#L244-L246 Cranelift's motivation for this is _runtime_ performance improvements in debug builds. Lifting this pass all the way to `-Zmir-opt-level=1` seems to come without significant perf overhead, so that's what I'm suggesting here.
- Loading branch information
Showing
5 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Test that MatchBranchSimplification doesn't ICE on a SwitchInt where | ||
// one of the targets is the block that the SwitchInt terminates. | ||
#![crate_type = "lib"] | ||
#![feature(core_intrinsics, custom_mir)] | ||
use std::intrinsics::mir::*; | ||
|
||
// EMIT_MIR switch_to_self.test.MatchBranchSimplification.diff | ||
#[custom_mir(dialect = "runtime", phase = "post-cleanup")] | ||
pub fn test(x: bool) { | ||
mir!( | ||
{ | ||
Goto(bb0) | ||
} | ||
bb0 = { | ||
match x { false => bb0, _ => bb1 } | ||
} | ||
bb1 = { | ||
match x { false => bb0, _ => bb1 } | ||
} | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/mir-opt/switch_to_self.test.MatchBranchSimplification.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- // MIR for `test` before MatchBranchSimplification | ||
+ // MIR for `test` after MatchBranchSimplification | ||
|
||
fn test(_1: bool) -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/switch_to_self.rs:+0:22: +0:22 | ||
|
||
bb0: { | ||
goto -> bb1; // scope 0 at $DIR/switch_to_self.rs:+3:13: +3:22 | ||
} | ||
|
||
bb1: { | ||
switchInt(_1) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/switch_to_self.rs:+6:13: +6:47 | ||
} | ||
|
||
bb2: { | ||
switchInt(_1) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/switch_to_self.rs:+9:13: +9:47 | ||
} | ||
} | ||
|