-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
1 deletion.
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
21 changes: 21 additions & 0 deletions
21
tests/mir-opt/instcombine_duplicate_switch_targets.assert_zero.InstCombine.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,21 @@ | ||
- // MIR for `assert_zero` before InstCombine | ||
+ // MIR for `assert_zero` after InstCombine | ||
|
||
fn assert_zero(_1: u8) -> u8 { | ||
let mut _0: u8; // return place in scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+0:37: +0:39 | ||
|
||
bb0: { | ||
- switchInt(_1) -> [0: bb2, 1: bb1, otherwise: bb1]; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+3:13: +7:14 | ||
+ switchInt(_1) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+3:13: +7:14 | ||
} | ||
|
||
bb1: { | ||
unreachable; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+10:13: +10:26 | ||
} | ||
|
||
bb2: { | ||
_0 = _1; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+13:13: +13:20 | ||
return; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+14:13: +14:21 | ||
} | ||
} | ||
|
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,27 @@ | ||
#![feature(custom_mir, core_intrinsics)] | ||
#![crate_type = "lib"] | ||
|
||
use std::intrinsics::mir::*; | ||
|
||
// unit-test: InstCombine | ||
|
||
// EMIT_MIR instcombine_duplicate_switch_targets.assert_zero.InstCombine.diff | ||
#[custom_mir(dialect = "runtime", phase = "post-cleanup")] | ||
pub unsafe fn assert_zero(x: u8) -> u8 { | ||
mir!( | ||
{ | ||
match x { | ||
0 => retblock, | ||
1 => unreachable, | ||
_ => unreachable, | ||
} | ||
} | ||
unreachable = { | ||
Unreachable() | ||
} | ||
retblock = { | ||
RET = x; | ||
Return() | ||
} | ||
) | ||
} |