2024-04-20 11:19:34 +00:00
|
|
|
//@ test-mir-pass: EarlyOtherwiseBranch
|
2024-02-21 14:44:48 +00:00
|
|
|
//@ compile-flags: -Zmir-enable-passes=+UnreachableEnumBranching
|
2020-08-01 23:47:52 +00:00
|
|
|
|
|
|
|
// must not optimize as it does not follow the pattern of
|
|
|
|
// left and right hand side being the same variant
|
|
|
|
|
|
|
|
// EMIT_MIR early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
|
2020-09-19 21:38:54 +00:00
|
|
|
fn noopt1(x: Option<u32>, y: Option<u32>) -> u32 {
|
2024-02-22 00:15:42 +00:00
|
|
|
// CHECK-LABEL: fn noopt1(
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK: [[LOCAL1:_.*]] = discriminant({{.*}});
|
|
|
|
// CHECK-NOT: Ne
|
|
|
|
// CHECK-NOT: discriminant
|
|
|
|
// CHECK: switchInt(move [[LOCAL1]]) -> [
|
|
|
|
// CHECK-NEXT: }
|
2020-09-19 21:38:54 +00:00
|
|
|
match (x, y) {
|
2020-08-01 23:47:52 +00:00
|
|
|
(Some(a), Some(b)) => 0,
|
|
|
|
(Some(a), None) => 1,
|
|
|
|
(None, Some(b)) => 2,
|
2020-09-19 21:38:54 +00:00
|
|
|
(None, None) => 3,
|
2020-08-01 23:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
noopt1(None, Some(0));
|
|
|
|
}
|