Skip to content

Commit 47766a2

Browse files
committed
Add -Zunsound-mir-opts to matches_reduce_branches.rs.
1 parent 2db4ff4 commit 47766a2

7 files changed

+174
-133
lines changed

tests/mir-opt/matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff

+33-28
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,42 @@
55
debug i => _1;
66
let mut _0: u128;
77
let mut _2: i128;
8+
+ let mut _3: i128;
89

910
bb0: {
1011
_2 = discriminant(_1);
11-
switchInt(move _2) -> [1: bb3, 2: bb4, 3: bb5, 340282366920938463463374607431768211455: bb2, otherwise: bb1];
12-
}
13-
14-
bb1: {
15-
unreachable;
16-
}
17-
18-
bb2: {
19-
_0 = const core::num::<impl u128>::MAX;
20-
goto -> bb6;
21-
}
22-
23-
bb3: {
24-
_0 = const 1_u128;
25-
goto -> bb6;
26-
}
27-
28-
bb4: {
29-
_0 = const 2_u128;
30-
goto -> bb6;
31-
}
32-
33-
bb5: {
34-
_0 = const 3_u128;
35-
goto -> bb6;
36-
}
37-
38-
bb6: {
12+
- switchInt(move _2) -> [1: bb3, 2: bb4, 3: bb5, 340282366920938463463374607431768211455: bb2, otherwise: bb1];
13+
- }
14+
-
15+
- bb1: {
16+
- unreachable;
17+
- }
18+
-
19+
- bb2: {
20+
- _0 = const core::num::<impl u128>::MAX;
21+
- goto -> bb6;
22+
- }
23+
-
24+
- bb3: {
25+
- _0 = const 1_u128;
26+
- goto -> bb6;
27+
- }
28+
-
29+
- bb4: {
30+
- _0 = const 2_u128;
31+
- goto -> bb6;
32+
- }
33+
-
34+
- bb5: {
35+
- _0 = const 3_u128;
36+
- goto -> bb6;
37+
- }
38+
-
39+
- bb6: {
40+
+ StorageLive(_3);
41+
+ _3 = move _2;
42+
+ _0 = _3 as u128 (IntToInt);
43+
+ StorageDead(_3);
3944
return;
4045
}
4146
}

tests/mir-opt/matches_reduce_branches.match_i16_i8.MatchBranchSimplification.diff

+28-23
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,37 @@
55
debug i => _1;
66
let mut _0: i8;
77
let mut _2: i16;
8+
+ let mut _3: i16;
89

910
bb0: {
1011
_2 = discriminant(_1);
11-
switchInt(move _2) -> [65535: bb3, 2: bb4, 65533: bb2, otherwise: bb1];
12-
}
13-
14-
bb1: {
15-
unreachable;
16-
}
17-
18-
bb2: {
19-
_0 = const -3_i8;
20-
goto -> bb5;
21-
}
22-
23-
bb3: {
24-
_0 = const -1_i8;
25-
goto -> bb5;
26-
}
27-
28-
bb4: {
29-
_0 = const 2_i8;
30-
goto -> bb5;
31-
}
32-
33-
bb5: {
12+
- switchInt(move _2) -> [65535: bb3, 2: bb4, 65533: bb2, otherwise: bb1];
13+
- }
14+
-
15+
- bb1: {
16+
- unreachable;
17+
- }
18+
-
19+
- bb2: {
20+
- _0 = const -3_i8;
21+
- goto -> bb5;
22+
- }
23+
-
24+
- bb3: {
25+
- _0 = const -1_i8;
26+
- goto -> bb5;
27+
- }
28+
-
29+
- bb4: {
30+
- _0 = const 2_i8;
31+
- goto -> bb5;
32+
- }
33+
-
34+
- bb5: {
35+
+ StorageLive(_3);
36+
+ _3 = move _2;
37+
+ _0 = _3 as i8 (IntToInt);
38+
+ StorageDead(_3);
3439
return;
3540
}
3641
}

tests/mir-opt/matches_reduce_branches.match_u8_i16.MatchBranchSimplification.diff

+23-18
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,32 @@
55
debug i => _1;
66
let mut _0: i16;
77
let mut _2: u8;
8+
+ let mut _3: u8;
89

910
bb0: {
1011
_2 = discriminant(_1);
11-
switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb1];
12-
}
13-
14-
bb1: {
15-
unreachable;
16-
}
17-
18-
bb2: {
19-
_0 = const 2_i16;
20-
goto -> bb4;
21-
}
22-
23-
bb3: {
24-
_0 = const 1_i16;
25-
goto -> bb4;
26-
}
27-
28-
bb4: {
12+
- switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb1];
13+
- }
14+
-
15+
- bb1: {
16+
- unreachable;
17+
- }
18+
-
19+
- bb2: {
20+
- _0 = const 2_i16;
21+
- goto -> bb4;
22+
- }
23+
-
24+
- bb3: {
25+
- _0 = const 1_i16;
26+
- goto -> bb4;
27+
- }
28+
-
29+
- bb4: {
30+
+ StorageLive(_3);
31+
+ _3 = move _2;
32+
+ _0 = _3 as i16 (IntToInt);
33+
+ StorageDead(_3);
2934
return;
3035
}
3136
}

tests/mir-opt/matches_reduce_branches.match_u8_u16.MatchBranchSimplification.diff

+28-23
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,37 @@
55
debug i => _1;
66
let mut _0: u16;
77
let mut _2: u8;
8+
+ let mut _3: u8;
89

910
bb0: {
1011
_2 = discriminant(_1);
11-
switchInt(move _2) -> [1: bb3, 2: bb4, 5: bb2, otherwise: bb1];
12-
}
13-
14-
bb1: {
15-
unreachable;
16-
}
17-
18-
bb2: {
19-
_0 = const 5_u16;
20-
goto -> bb5;
21-
}
22-
23-
bb3: {
24-
_0 = const 1_u16;
25-
goto -> bb5;
26-
}
27-
28-
bb4: {
29-
_0 = const 2_u16;
30-
goto -> bb5;
31-
}
32-
33-
bb5: {
12+
- switchInt(move _2) -> [1: bb3, 2: bb4, 5: bb2, otherwise: bb1];
13+
- }
14+
-
15+
- bb1: {
16+
- unreachable;
17+
- }
18+
-
19+
- bb2: {
20+
- _0 = const 5_u16;
21+
- goto -> bb5;
22+
- }
23+
-
24+
- bb3: {
25+
- _0 = const 1_u16;
26+
- goto -> bb5;
27+
- }
28+
-
29+
- bb4: {
30+
- _0 = const 2_u16;
31+
- goto -> bb5;
32+
- }
33+
-
34+
- bb5: {
35+
+ StorageLive(_3);
36+
+ _3 = move _2;
37+
+ _0 = _3 as u16 (IntToInt);
38+
+ StorageDead(_3);
3439
return;
3540
}
3641
}

tests/mir-opt/matches_reduce_branches.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ test-mir-pass: MatchBranchSimplification
2+
//@ compile-flags: -Zunsound-mir-opts
23

34
#![feature(repr128)]
45
#![feature(core_intrinsics)]
@@ -75,7 +76,9 @@ enum EnumAu8 {
7576
// EMIT_MIR matches_reduce_branches.match_u8_i16.MatchBranchSimplification.diff
7677
fn match_u8_i16(i: EnumAu8) -> i16 {
7778
// CHECK-LABEL: fn match_u8_i16(
78-
// CHECK: switchInt
79+
// CHECK-NOT: switchInt
80+
// CHECK: _0 = _3 as i16 (IntToInt);
81+
// CHECH: return
7982
match i {
8083
EnumAu8::A => 1,
8184
EnumAu8::B => 2,
@@ -144,7 +147,9 @@ enum EnumBu8 {
144147
// EMIT_MIR matches_reduce_branches.match_u8_u16.MatchBranchSimplification.diff
145148
fn match_u8_u16(i: EnumBu8) -> u16 {
146149
// CHECK-LABEL: fn match_u8_u16(
147-
// CHECK: switchInt
150+
// CHECK-NOT: switchInt
151+
// CHECK: _0 = _3 as u16 (IntToInt);
152+
// CHECH: return
148153
match i {
149154
EnumBu8::A => 1,
150155
EnumBu8::B => 2,
@@ -200,7 +205,9 @@ enum EnumAi8 {
200205
// EMIT_MIR matches_reduce_branches.match_i8_i16.MatchBranchSimplification.diff
201206
fn match_i8_i16(i: EnumAi8) -> i16 {
202207
// CHECK-LABEL: fn match_i8_i16(
203-
// CHECK: switchInt
208+
// CHECK-NOT: switchInt
209+
// CHECK: _0 = _3 as i16 (IntToInt);
210+
// CHECH: return
204211
match i {
205212
EnumAi8::A => -1,
206213
EnumAi8::B => 2,
@@ -229,7 +236,9 @@ enum EnumAi16 {
229236
// EMIT_MIR matches_reduce_branches.match_i16_i8.MatchBranchSimplification.diff
230237
fn match_i16_i8(i: EnumAi16) -> i8 {
231238
// CHECK-LABEL: fn match_i16_i8(
232-
// CHECK: switchInt
239+
// CHECK-NOT: switchInt
240+
// CHECK: _0 = _3 as i8 (IntToInt);
241+
// CHECH: return
233242
match i {
234243
EnumAi16::A => -1,
235244
EnumAi16::B => 2,
@@ -248,7 +257,9 @@ enum EnumAi128 {
248257
// EMIT_MIR matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff
249258
fn match_i128_u128(i: EnumAi128) -> u128 {
250259
// CHECK-LABEL: fn match_i128_u128(
251-
// CHECK: switchInt
260+
// CHECK-NOT: switchInt
261+
// CHECK: _0 = _3 as u128 (IntToInt);
262+
// CHECH: return
252263
match i {
253264
EnumAi128::A => 1,
254265
EnumAi128::B => 2,

tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff

+23-18
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,32 @@
55
debug e => _1;
66
let mut _0: u8;
77
let mut _2: isize;
8+
+ let mut _3: isize;
89

910
bb0: {
1011
_2 = discriminant(_1);
11-
switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
12-
}
13-
14-
bb1: {
15-
unreachable;
16-
}
17-
18-
bb2: {
19-
_0 = const 1_u8;
20-
goto -> bb4;
21-
}
22-
23-
bb3: {
24-
_0 = const 0_u8;
25-
goto -> bb4;
26-
}
27-
28-
bb4: {
12+
- switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
13+
- }
14+
-
15+
- bb1: {
16+
- unreachable;
17+
- }
18+
-
19+
- bb2: {
20+
- _0 = const 1_u8;
21+
- goto -> bb4;
22+
- }
23+
-
24+
- bb3: {
25+
- _0 = const 0_u8;
26+
- goto -> bb4;
27+
- }
28+
-
29+
- bb4: {
30+
+ StorageLive(_3);
31+
+ _3 = move _2;
32+
+ _0 = _3 as u8 (IntToInt);
33+
+ StorageDead(_3);
2934
return;
3035
}
3136
}

0 commit comments

Comments
 (0)