Skip to content

Commit 9cba260

Browse files
committedOct 1, 2020
Auto merge of #74839 - alarsyo:multiple_return_terminators, r=oli-obk
Implement multiple return terminator optimization Closes #72022
2 parents fc42fb8 + 46c0bd3 commit 9cba260

12 files changed

+149
-122
lines changed
 

‎compiler/rustc_mir/src/transform/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub mod inline;
3333
pub mod instcombine;
3434
pub mod instrument_coverage;
3535
pub mod match_branches;
36+
pub mod multiple_return_terminators;
3637
pub mod no_landing_pads;
3738
pub mod nrvo;
3839
pub mod promote_consts;
@@ -464,6 +465,7 @@ fn run_optimization_passes<'tcx>(
464465
&remove_unneeded_drops::RemoveUnneededDrops,
465466
&match_branches::MatchBranchSimplification,
466467
// inst combine is after MatchBranchSimplification to clean up Ne(_1, false)
468+
&multiple_return_terminators::MultipleReturnTerminators,
467469
&instcombine::InstCombine,
468470
&const_prop::ConstProp,
469471
&simplify_branches::SimplifyBranches::new("after-const-prop"),
@@ -478,6 +480,7 @@ fn run_optimization_passes<'tcx>(
478480
&simplify::SimplifyCfg::new("final"),
479481
&nrvo::RenameReturnPlace,
480482
&simplify::SimplifyLocals,
483+
&multiple_return_terminators::MultipleReturnTerminators,
481484
];
482485

483486
// Optimizations to run even if mir optimizations have been disabled.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//! This pass removes jumps to basic blocks containing only a return, and replaces them with a
2+
//! return instead.
3+
4+
use crate::transform::{simplify, MirPass, MirSource};
5+
use rustc_index::bit_set::BitSet;
6+
use rustc_middle::mir::*;
7+
use rustc_middle::ty::TyCtxt;
8+
9+
pub struct MultipleReturnTerminators;
10+
11+
impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
12+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
13+
if tcx.sess.opts.debugging_opts.mir_opt_level < 3 {
14+
return;
15+
}
16+
17+
// find basic blocks with no statement and a return terminator
18+
let mut bbs_simple_returns = BitSet::new_empty(body.basic_blocks().len());
19+
let bbs = body.basic_blocks_mut();
20+
for idx in bbs.indices() {
21+
if bbs[idx].statements.is_empty()
22+
&& bbs[idx].terminator().kind == TerminatorKind::Return
23+
{
24+
bbs_simple_returns.insert(idx);
25+
}
26+
}
27+
28+
for bb in bbs {
29+
if let TerminatorKind::Goto { target } = bb.terminator().kind {
30+
if bbs_simple_returns.contains(target) {
31+
bb.terminator_mut().kind = TerminatorKind::Return;
32+
}
33+
}
34+
}
35+
36+
simplify::remove_dead_blocks(body)
37+
}
38+
}

‎src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-after-copy-prop.after.diff

+18-24
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
+ StorageLive(_35); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
9292
+ _35 = Ne(_34, _11); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
9393
+ StorageDead(_34); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
94-
+ switchInt(move _35) -> [false: bb8, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
94+
+ switchInt(move _35) -> [false: bb7, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
9595
}
9696

9797
bb1: {
@@ -107,10 +107,9 @@
107107
StorageDead(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:27: 27:28
108108
- StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7
109109
- StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:1: 29:2
110-
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:14: 27:28
111110
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7
112111
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:1: 29:2
113-
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:14: 27:28
112+
return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:14: 27:28
114113
}
115114

116115
+ bb2: {
@@ -131,7 +130,7 @@
131130
+ nop; // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
132131
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
133132
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
134-
+ goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
133+
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
135134
+ }
136135
+
137136
bb3: {
@@ -154,7 +153,7 @@
154153
+ nop; // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
155154
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
156155
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
157-
+ goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
156+
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
158157
}
159158

160159
bb4: {
@@ -177,7 +176,7 @@
177176
+ nop; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
178177
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
179178
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
180-
+ goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
179+
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
181180
}
182181

183182
bb5: {
@@ -200,7 +199,7 @@
200199
+ nop; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
201200
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
202201
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
203-
+ goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
202+
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
204203
}
205204

206205
bb6: {
@@ -221,7 +220,11 @@
221220
- StorageDead(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
222221
- StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
223222
- StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
224-
- goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
223+
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
224+
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
225+
+ discriminant(_0) = 0; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
226+
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7
227+
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:1: 29:2
225228
+ return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
226229
}
227230

@@ -243,15 +246,10 @@
243246
- StorageDead(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
244247
- StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
245248
- StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
246-
- goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
247-
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
248-
+ discriminant(_0) = 0; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
249-
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7
250-
+ nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:1: 29:2
251-
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
252-
}
253-
254-
bb8: {
249+
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
250+
- }
251+
-
252+
- bb8: {
255253
- StorageLive(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19
256254
- _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19
257255
- StorageLive(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
@@ -269,7 +267,7 @@
269267
- StorageDead(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
270268
- StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
271269
- StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
272-
- goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
270+
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
273271
- }
274272
-
275273
- bb9: {
@@ -290,19 +288,15 @@
290288
- StorageDead(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
291289
- StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
292290
- StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
293-
- goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
291+
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
294292
- }
295293
-
296294
- bb10: {
297-
- return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
298-
- }
299-
-
300-
- bb11: {
301295
- ((_0 as Ok).0: ViewportPercentageLength) = move _3; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
302296
- discriminant(_0) = 0; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
303297
- StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7
304298
- StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:1: 29:2
305-
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
299+
- return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
306300
+ StorageDead(_35); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:21: 23:30
307301
+ switchInt(_11) -> [0_isize: bb2, 1_isize: bb3, 2_isize: bb4, 3_isize: bb5, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:21: 23:30
308302
}

‎src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff

+12-19
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
+ StorageLive(_35); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
7474
+ _35 = Ne(_34, _11); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
7575
+ StorageDead(_34); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
76-
+ switchInt(move _35) -> [false: bb8, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
76+
+ switchInt(move _35) -> [false: bb7, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:11: 23:18
7777
}
7878

7979
bb1: {
@@ -89,8 +89,7 @@
8989
StorageDead(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:27: 27:28
9090
StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7
9191
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:1: 29:2
92-
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:14: 27:28
93-
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:14: 27:28
92+
return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:14: 27:28
9493
}
9594

9695
- bb3: {
@@ -127,8 +126,8 @@
127126
StorageDead(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
128127
StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
129128
StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
130-
- goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
131-
+ goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
129+
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
130+
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
132131
}
133132

134133
- bb7: {
@@ -150,8 +149,8 @@
150149
StorageDead(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
151150
StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
152151
StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
153-
- goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
154-
+ goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
152+
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
153+
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
155154
}
156155

157156
- bb8: {
@@ -173,8 +172,8 @@
173172
StorageDead(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
174173
StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
175174
StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
176-
- goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
177-
+ goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
175+
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
176+
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
178177
}
179178

180179
- bb9: {
@@ -196,26 +195,20 @@
196195
StorageDead(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
197196
StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
198197
StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
199-
- goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
200-
+ goto -> bb7; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
198+
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
199+
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
201200
}
202201

203202
- bb10: {
204203
+ bb6: {
205-
return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
206-
}
207-
208-
- bb11: {
209-
+ bb7: {
210204
((_0 as Ok).0: ViewportPercentageLength) = move _3; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
211205
discriminant(_0) = 0; // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
212206
StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7
213207
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:1: 29:2
214-
- goto -> bb10; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
215-
+ goto -> bb6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
208+
return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:29:2: 29:2
216209
+ }
217210
+
218-
+ bb8: {
211+
+ bb7: {
219212
+ StorageDead(_35); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:21: 23:30
220213
+ switchInt(_11) -> [0_isize: bb2, 1_isize: bb3, 2_isize: bb4, 3_isize: bb5, otherwise: bb1]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:21: 23:30
221214
}

‎src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff

+12-16
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
_0 = const (); // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
107107
StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7
108108
StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2
109-
goto -> bb3; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
109+
return; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
110110
}
111111

112112
bb2: {
@@ -153,14 +153,10 @@
153153
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
154154
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
155155
StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
156-
switchInt(_15) -> [false: bb4, otherwise: bb5]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
156+
switchInt(_15) -> [false: bb3, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
157157
}
158158

159159
bb3: {
160-
return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
161-
}
162-
163-
bb4: {
164160
_8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
165161
StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
166162
StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -170,10 +166,10 @@
170166
_0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2
171167
StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2
172168
StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2
173-
goto -> bb3; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
169+
return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
174170
}
175171

176-
bb5: {
172+
bb4: {
177173
StorageLive(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
178174
StorageLive(_20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
179175
StorageLive(_21); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
@@ -224,24 +220,24 @@
224220
StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
225221
StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
226222
_47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
227-
_46 = transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
223+
_46 = transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
228224
// mir::Constant
229225
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
230226
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar(<ZST>)) }
231227
}
232228

233-
bb6: {
229+
bb5: {
234230
StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
235231
StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
236232
StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
237233
_49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
238-
_48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb7; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
234+
_48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
239235
// mir::Constant
240236
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
241237
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar(<ZST>)) }
242238
}
243239

244-
bb7: {
240+
bb6: {
245241
StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
246242
(_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
247243
(_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
@@ -260,24 +256,24 @@
260256
StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
261257
StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
262258
_51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
263-
_50 = transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
259+
_50 = transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
264260
// mir::Constant
265261
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
266262
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar(<ZST>)) }
267263
}
268264

269-
bb8: {
265+
bb7: {
270266
StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
271267
StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
272268
StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
273269
_53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
274-
_52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb9; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
270+
_52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
275271
// mir::Constant
276272
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
277273
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar(<ZST>)) }
278274
}
279275

280-
bb9: {
276+
bb8: {
281277
StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
282278
(_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
283279
(_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL

‎src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff

+12-16
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
_0 = const (); // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
107107
StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7
108108
StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2
109-
goto -> bb3; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
109+
return; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23
110110
}
111111

112112
bb2: {
@@ -153,14 +153,10 @@
153153
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
154154
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
155155
StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
156-
switchInt(_15) -> [false: bb4, otherwise: bb5]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
156+
switchInt(_15) -> [false: bb3, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
157157
}
158158

159159
bb3: {
160-
return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
161-
}
162-
163-
bb4: {
164160
_8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
165161
StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
166162
StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -170,10 +166,10 @@
170166
_0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2
171167
StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2
172168
StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2
173-
goto -> bb3; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
169+
return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2
174170
}
175171

176-
bb5: {
172+
bb4: {
177173
StorageLive(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
178174
StorageLive(_20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
179175
StorageLive(_21); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
@@ -224,24 +220,24 @@
224220
StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
225221
StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
226222
_47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
227-
_46 = transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
223+
_46 = transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
228224
// mir::Constant
229225
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
230226
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar(<ZST>)) }
231227
}
232228

233-
bb6: {
229+
bb5: {
234230
StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
235231
StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
236232
StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
237233
_49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
238-
_48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb7; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
234+
_48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
239235
// mir::Constant
240236
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
241237
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar(<ZST>)) }
242238
}
243239

244-
bb7: {
240+
bb6: {
245241
StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
246242
(_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
247243
(_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
@@ -260,24 +256,24 @@
260256
StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
261257
StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
262258
_51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
263-
_50 = transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
259+
_50 = transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
264260
// mir::Constant
265261
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
266262
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute::<for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar(<ZST>)) }
267263
}
268264

269-
bb8: {
265+
bb7: {
270266
StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
271267
StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
272268
StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
273269
_53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
274-
_52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb9; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
270+
_52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
275271
// mir::Constant
276272
// + span: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
277273
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar(<ZST>)) }
278274
}
279275

280-
bb9: {
276+
bb8: {
281277
StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
282278
(_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
283279
(_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Z mir-opt-level=3
2+
// EMIT_MIR multiple_return_terminators.test.MultipleReturnTerminators.diff
3+
4+
fn test(x: bool) {
5+
if x {
6+
// test
7+
} else {
8+
// test
9+
}
10+
}
11+
12+
fn main() {
13+
test(true)
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
- // MIR for `test` before MultipleReturnTerminators
2+
+ // MIR for `test` after MultipleReturnTerminators
3+
4+
fn test(_1: bool) -> () {
5+
debug x => _1; // in scope 0 at $DIR/multiple_return_terminators.rs:4:9: 4:10
6+
let mut _0: (); // return place in scope 0 at $DIR/multiple_return_terminators.rs:4:18: 4:18
7+
let mut _2: bool; // in scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
8+
9+
bb0: {
10+
StorageLive(_2); // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
11+
_2 = _1; // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
12+
switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
13+
}
14+
15+
bb1: {
16+
_0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:7:12: 9:6
17+
goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
18+
}
19+
20+
bb2: {
21+
_0 = const (); // scope 0 at $DIR/multiple_return_terminators.rs:5:10: 7:6
22+
goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
23+
}
24+
25+
bb3: {
26+
StorageDead(_2); // scope 0 at $DIR/multiple_return_terminators.rs:10:1: 10:2
27+
return; // scope 0 at $DIR/multiple_return_terminators.rs:10:2: 10:2
28+
}
29+
}
30+

‎src/test/mir-opt/not_equal_false.opt.InstCombine.diff

+8-33
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,35 @@
1313
StorageLive(_2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
1414
_3 = discriminant(_1); // scope 0 at $DIR/not_equal_false.rs:4:17: 4:21
1515
_2 = Eq(_3, const 0_isize); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
16-
goto -> bb7; // scope 0 at $DIR/not_equal_false.rs:4:17: 4:21
16+
goto -> bb4; // scope 0 at $DIR/not_equal_false.rs:4:17: 4:21
1717
}
1818

1919
bb1: {
2020
_0 = const true; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
21-
goto -> bb4; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
21+
goto -> bb3; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
2222
}
2323

2424
bb2: {
25-
_0 = const false; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
26-
goto -> bb4; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
27-
}
28-
29-
bb3: {
3025
StorageLive(_4); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
3126
_5 = discriminant(_1); // scope 0 at $DIR/not_equal_false.rs:4:38: 4:45
3227
_4 = Eq(_5, const 1_isize); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
33-
goto -> bb10; // scope 0 at $DIR/not_equal_false.rs:4:38: 4:45
28+
goto -> bb5; // scope 0 at $DIR/not_equal_false.rs:4:38: 4:45
3429
}
3530

36-
bb4: {
31+
bb3: {
3732
StorageDead(_4); // scope 0 at $DIR/not_equal_false.rs:4:45: 4:46
3833
StorageDead(_2); // scope 0 at $DIR/not_equal_false.rs:4:45: 4:46
3934
return; // scope 0 at $DIR/not_equal_false.rs:5:2: 5:2
4035
}
4136

42-
bb5: {
43-
_2 = const false; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
44-
goto -> bb7; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
45-
}
46-
47-
bb6: {
48-
_2 = const true; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
49-
goto -> bb7; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
50-
}
51-
52-
bb7: {
53-
switchInt(move _2) -> [false: bb3, otherwise: bb1]; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
54-
}
55-
56-
bb8: {
57-
_4 = const false; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
58-
goto -> bb10; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
59-
}
60-
61-
bb9: {
62-
_4 = const true; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
63-
goto -> bb10; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
37+
bb4: {
38+
switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
6439
}
6540

66-
bb10: {
41+
bb5: {
6742
- _0 = Ne(_4, const false); // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
6843
+ _0 = _4; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
69-
goto -> bb4; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
44+
goto -> bb3; // scope 0 at $DIR/not_equal_false.rs:4:5: 4:46
7045
}
7146
}
7247

‎src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff

-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@
6262
+ nop; // scope 1 at $DIR/simplify_try.rs:8:5: 8:10
6363
+ nop; // scope 0 at $DIR/simplify_try.rs:7:15: 7:16
6464
StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:9:1: 9:2
65-
goto -> bb2; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
66-
}
67-
68-
bb2: {
6965
return; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
7066
}
7167
}

‎src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff

+2-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
- discriminant(_0) = 0; // scope 1 at $DIR/simplify_try.rs:8:5: 8:10
6868
- StorageDead(_11); // scope 1 at $DIR/simplify_try.rs:8:9: 8:10
6969
StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:9:1: 9:2
70-
goto -> bb3; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
70+
return; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
7171
}
7272

7373
bb2: {
@@ -88,11 +88,7 @@
8888
+ _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL
8989
StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:7:15: 7:16
9090
StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:9:1: 9:2
91-
goto -> bb3; // scope 0 at $DIR/simplify_try.rs:7:14: 7:15
92-
}
93-
94-
bb3: {
95-
return; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
91+
return; // scope 0 at $DIR/simplify_try.rs:7:14: 7:15
9692
}
9793
}
9894

‎src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir

-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i
5252
_0 = move _3; // scope 1 at $DIR/simplify_try.rs:8:5: 8:10
5353
StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:7:15: 7:16
5454
StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:9:1: 9:2
55-
goto -> bb2; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
56-
}
57-
58-
bb2: {
5955
return; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2
6056
}
6157
}

0 commit comments

Comments
 (0)
Please sign in to comment.