Skip to content

Commit 65efa5b

Browse files
committed
Add FileCheck directives to the new tests.
1 parent 75d2e67 commit 65efa5b

File tree

2 files changed

+42
-51
lines changed

2 files changed

+42
-51
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
11
// MIR for `disjoint_ranges` after SimplifyCfg-initial
22

3-
fn disjoint_ranges() -> () {
4-
let mut _0: ();
5-
let _1: i32;
6-
let _3: i32;
3+
fn disjoint_ranges(_1: i32, _2: bool) -> u32 {
4+
debug x => _1;
5+
debug b => _2;
6+
let mut _0: u32;
7+
let mut _3: bool;
78
let mut _4: bool;
89
let mut _5: bool;
910
let mut _6: bool;
10-
let mut _7: bool;
11-
let mut _8: &i32;
12-
let mut _9: bool;
13-
scope 1 {
14-
debug x => _1;
15-
let _2: bool;
16-
scope 2 {
17-
debug b => _2;
18-
}
19-
}
11+
let mut _7: &i32;
12+
let mut _8: bool;
2013

2114
bb0: {
22-
StorageLive(_1);
23-
_1 = const 3_i32;
24-
FakeRead(ForLet(None), _1);
25-
StorageLive(_2);
26-
_2 = const true;
27-
FakeRead(ForLet(None), _2);
28-
StorageLive(_3);
2915
PlaceMention(_1);
30-
_6 = Le(const 0_i32, _1);
31-
switchInt(move _6) -> [0: bb3, otherwise: bb8];
16+
_5 = Le(const 0_i32, _1);
17+
switchInt(move _5) -> [0: bb3, otherwise: bb8];
3218
}
3319

3420
bb1: {
35-
_3 = const 3_i32;
21+
_0 = const 3_u32;
3622
goto -> bb14;
3723
}
3824

@@ -41,8 +27,8 @@ fn disjoint_ranges() -> () {
4127
}
4228

4329
bb3: {
44-
_4 = Le(const 10_i32, _1);
45-
switchInt(move _4) -> [0: bb5, otherwise: bb7];
30+
_3 = Le(const 10_i32, _1);
31+
switchInt(move _3) -> [0: bb5, otherwise: bb7];
4632
}
4733

4834
bb4: {
@@ -58,49 +44,45 @@ fn disjoint_ranges() -> () {
5844
}
5945

6046
bb7: {
61-
_5 = Le(_1, const 20_i32);
62-
switchInt(move _5) -> [0: bb5, otherwise: bb4];
47+
_4 = Le(_1, const 20_i32);
48+
switchInt(move _4) -> [0: bb5, otherwise: bb4];
6349
}
6450

6551
bb8: {
66-
_7 = Lt(_1, const 10_i32);
67-
switchInt(move _7) -> [0: bb3, otherwise: bb2];
52+
_6 = Lt(_1, const 10_i32);
53+
switchInt(move _6) -> [0: bb3, otherwise: bb2];
6854
}
6955

7056
bb9: {
71-
_8 = &fake _1;
72-
StorageLive(_9);
73-
_9 = _2;
74-
switchInt(move _9) -> [0: bb11, otherwise: bb10];
57+
_7 = &fake _1;
58+
StorageLive(_8);
59+
_8 = _2;
60+
switchInt(move _8) -> [0: bb11, otherwise: bb10];
7561
}
7662

7763
bb10: {
78-
StorageDead(_9);
79-
FakeRead(ForMatchGuard, _8);
80-
_3 = const 0_i32;
64+
StorageDead(_8);
65+
FakeRead(ForMatchGuard, _7);
66+
_0 = const 0_u32;
8167
goto -> bb14;
8268
}
8369

8470
bb11: {
85-
StorageDead(_9);
71+
StorageDead(_8);
8672
falseEdge -> [real: bb1, imaginary: bb4];
8773
}
8874

8975
bb12: {
90-
_3 = const 1_i32;
76+
_0 = const 1_u32;
9177
goto -> bb14;
9278
}
9379

9480
bb13: {
95-
_3 = const 2_i32;
81+
_0 = const 2_u32;
9682
goto -> bb14;
9783
}
9884

9985
bb14: {
100-
StorageDead(_3);
101-
_0 = const ();
102-
StorageDead(_2);
103-
StorageDead(_1);
10486
return;
10587
}
10688
}

Diff for: tests/mir-opt/building/match/sort_candidates.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
// skip-filecheck
21
// Check specific cases of sorting candidates in match lowering.
32
#![feature(exclusive_range_pattern)]
43

54
// EMIT_MIR sort_candidates.constant_eq.SimplifyCfg-initial.after.mir
65
fn constant_eq(s: &str, b: bool) -> u32 {
76
// Check that we only test "a" once
7+
8+
// CHECK-LABEL: fn constant_eq(
9+
// CHECK: bb0: {
10+
// CHECK: [[a:_.*]] = const "a";
11+
// CHECK-NOT: {{_.*}} = const "a";
812
match (s, b) {
913
("a", _) if true => 1,
1014
("b", true) => 2,
@@ -15,18 +19,23 @@ fn constant_eq(s: &str, b: bool) -> u32 {
1519
}
1620

1721
// EMIT_MIR sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir
18-
fn disjoint_ranges() {
19-
let x = 3;
20-
let b = true;
22+
fn disjoint_ranges(x: i32, b: bool) -> u32 {
23+
// When `(0..=10).contains(x) && !b`, we should jump to the last arm without testing the two
24+
// other candidates.
2125

22-
// When `(0..=10).contains(x) && !b`, we should jump to the last arm
23-
// without testing two other candidates.
26+
// CHECK-LABEL: fn disjoint_ranges(
27+
// CHECK: debug b => _2;
28+
// CHECK: bb0: {
29+
// CHECK: switchInt(_2) -> [0: [[jump:bb.*]], otherwise: {{bb.*}}];
30+
// CHECK: [[jump]]: {
31+
// CHECK-NEXT: _0 = const 3_u32;
32+
// CHECK-NEXT: return;
2433
match x {
2534
0..10 if b => 0,
2635
10..=20 => 1,
2736
-1 => 2,
2837
_ => 3,
29-
};
38+
}
3039
}
3140

3241
fn main() {}

0 commit comments

Comments
 (0)