Skip to content

Commit 99851c4

Browse files
committed
bless mir-opt
1 parent 4c6ddc0 commit 99851c4

4 files changed

+28
-438
lines changed

tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff

Lines changed: 7 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,7 @@
1111
+ debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
1212
+ debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
1313
+ let mut _5: u16; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
14-
+ let mut _6: std::option::Option<u16>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
15-
+ let mut _7: std::result::Result<u16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
1614
+ scope 2 {
17-
+ scope 3 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
18-
+ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
19-
+ scope 4 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
20-
+ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
21-
+ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
22-
+ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
23-
+ let mut _10: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
24-
+ }
25-
+ }
26-
+ scope 5 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
27-
+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
28-
+ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
29-
+ let _12: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
30-
+ scope 6 {
31-
+ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL
32-
+ }
33-
+ scope 7 {
34-
+ scope 8 {
35-
+ debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
36-
+ }
37-
+ }
38-
+ }
39-
+ scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
40-
+ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
41-
+ let mut _13: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
42-
+ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
43-
+ scope 10 {
44-
+ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL
45-
+ }
46-
+ scope 11 {
47-
+ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
48-
+ scope 14 {
49-
+ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
50-
+ }
51-
+ }
52-
+ }
53-
+ }
54-
+ scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL
55-
+ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL
56-
+ }
57-
+ }
5815
+ }
5916
+ }
6017

@@ -64,81 +21,21 @@
6421
StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22
6522
_4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22
6623
- _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23
67-
- // mir::Constant
24+
+ StorageLive(_5); // scope 0 at $DIR/unchecked_shifts.rs:+1:7: +1:23
25+
+ _5 = _4 as u16 (IntToInt); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
26+
+ _0 = unchecked_shl::<u16>(_3, _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
27+
// mir::Constant
6828
- // + span: $DIR/unchecked_shifts.rs:11:7: 11:20
6929
- // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::<impl u16>::unchecked_shl}, val: Value(<ZST>) }
70-
+ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
71-
+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
72-
+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
73-
+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
74-
+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
75-
+ _9 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
76-
+ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
77-
+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
78-
+ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
30+
+ // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
31+
+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) }
7932
}
8033

8134
bb1: {
82-
+ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
83-
+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
84-
+ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
85-
+ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
86-
+ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
87-
+ }
88-
+
89-
+ bb2: {
90-
+ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
35+
+ StorageDead(_5); // scope 0 at $DIR/unchecked_shifts.rs:+1:7: +1:23
9136
StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
9237
StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23
9338
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
94-
+ }
95-
+
96-
+ bb3: {
97-
+ _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
98-
+ // mir::Constant
99-
+ // + span: no-location
100-
+ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) }
101-
+ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
102-
+ }
103-
+
104-
+ bb4: {
105-
+ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
106-
+ _10 = _4 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
107-
+ _7 = Result::<u16, TryFromIntError>::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
108-
+ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
109-
+ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
110-
+ }
111-
+
112-
+ bb5: {
113-
+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
114-
+ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
115-
+ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
116-
+ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
117-
+ }
118-
+
119-
+ bb6: {
120-
+ _6 = Option::<u16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
121-
+ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
122-
+ }
123-
+
124-
+ bb7: {
125-
+ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
126-
+ }
127-
+
128-
+ bb8: {
129-
+ _12 = move ((_7 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
130-
+ _6 = Option::<u16>::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL
131-
+ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
132-
+ }
133-
+
134-
+ bb9: {
135-
+ _5 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
136-
+ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
137-
+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
138-
+ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
139-
+ // mir::Constant
140-
+ // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
141-
+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) }
14239
}
14340
}
14441

tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir

Lines changed: 7 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -8,123 +8,21 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 {
88
debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
99
debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
1010
let mut _3: u16; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
11-
let mut _4: std::option::Option<u16>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
12-
let mut _5: std::result::Result<u16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
1311
scope 2 {
14-
scope 3 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
15-
debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
16-
scope 4 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
17-
debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
18-
let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
19-
let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
20-
let mut _8: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
21-
}
22-
}
23-
scope 5 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
24-
debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
25-
let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
26-
let _10: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
27-
scope 6 {
28-
debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL
29-
}
30-
scope 7 {
31-
scope 8 {
32-
debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
33-
}
34-
}
35-
}
36-
scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
37-
debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
38-
let mut _11: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
39-
let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
40-
scope 10 {
41-
debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL
42-
}
43-
scope 11 {
44-
scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
45-
scope 14 {
46-
scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
47-
}
48-
}
49-
}
50-
}
51-
scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL
52-
debug self => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL
53-
}
54-
}
5512
}
5613
}
5714

5815
bb0: {
59-
StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
60-
StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
61-
StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
62-
StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
63-
StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
64-
_7 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
65-
_6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
66-
StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
67-
switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
16+
StorageLive(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:7: +1:23
17+
_3 = _2 as u16 (IntToInt); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
18+
_0 = unchecked_shl::<u16>(_1, _3) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
19+
// mir::Constant
20+
// + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
21+
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) }
6822
}
6923

7024
bb1: {
71-
StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
72-
StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
73-
StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
74-
_12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
75-
switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
76-
}
77-
78-
bb2: {
79-
StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
25+
StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:7: +1:23
8026
return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2
8127
}
82-
83-
bb3: {
84-
_5 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
85-
// mir::Constant
86-
// + span: no-location
87-
// + literal: Const { ty: TryFromIntError, val: Value(<ZST>) }
88-
goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
89-
}
90-
91-
bb4: {
92-
StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
93-
_8 = _2 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
94-
_5 = Result::<u16, TryFromIntError>::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
95-
StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
96-
goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
97-
}
98-
99-
bb5: {
100-
StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL
101-
StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
102-
_9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
103-
switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
104-
}
105-
106-
bb6: {
107-
_4 = Option::<u16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
108-
goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL
109-
}
110-
111-
bb7: {
112-
unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
113-
}
114-
115-
bb8: {
116-
_10 = move ((_5 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
117-
_4 = Option::<u16>::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL
118-
goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL
119-
}
120-
121-
bb9: {
122-
_3 = move ((_4 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL
123-
StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
124-
StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
125-
_0 = unchecked_shl::<u16>(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
126-
// mir::Constant
127-
// + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
128-
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) }
129-
}
13028
}

0 commit comments

Comments
 (0)