about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2024-06-30 12:29:46 +0200
committerNadrieril <nadrieril+git@gmail.com>2024-07-09 22:47:35 +0200
commit8a222ffd6bb37a79bf517b3552008d9695cc8ae1 (patch)
tree1add839dd64c124ad90ace068f2db062c1487853
parentc5062f73181778af278321827ceedf1682ee0a8b (diff)
downloadrust-8a222ffd6bb37a79bf517b3552008d9695cc8ae1.tar.gz
rust-8a222ffd6bb37a79bf517b3552008d9695cc8ae1.zip
Don't try to save an extra block
This is preparation for the next commit.
-rw-r--r--compiler/rustc_mir_build/src/build/matches/mod.rs22
-rw-r--r--tests/mir-opt/building/issue_101867.main.built.after.mir18
-rw-r--r--tests/mir-opt/building/issue_49232.main.built.after.mir34
-rw-r--r--tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir122
-rw-r--r--tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir50
-rw-r--r--tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir54
-rw-r--r--tests/mir-opt/building/match/match_false_edges.main.built.after.mir34
-rw-r--r--tests/mir-opt/building/match/simple_match.match_bool.built.after.mir8
-rw-r--r--tests/mir-opt/building/match/simple_match.match_enum.built.after.mir26
-rw-r--r--tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir28
-rw-r--r--tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff48
-rw-r--r--tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff48
-rw-r--r--tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff26
-rw-r--r--tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff26
-rw-r--r--tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir8
15 files changed, 284 insertions, 268 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs
index cc8a0e4b038..458e2c5c406 100644
--- a/compiler/rustc_mir_build/src/build/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/build/matches/mod.rs
@@ -2021,19 +2021,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
 
         // The block that we should branch to if none of the
         // `target_candidates` match.
-        let remainder_start = if !remaining_candidates.is_empty() {
-            let remainder_start = self.cfg.start_new_block();
-            self.match_candidates(
-                span,
-                scrutinee_span,
-                remainder_start,
-                otherwise_block,
-                remaining_candidates,
-            );
-            remainder_start
-        } else {
-            otherwise_block
-        };
+        let remainder_start = self.cfg.start_new_block();
 
         // For each outcome of test, process the candidates that still apply.
         let target_blocks: FxIndexMap<_, _> = target_candidates
@@ -2061,6 +2049,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             &test,
             target_blocks,
         );
+
+        self.match_candidates(
+            span,
+            scrutinee_span,
+            remainder_start,
+            otherwise_block,
+            remaining_candidates,
+        );
     }
 }
 
diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir
index 5c50b3db5ca..728b5b23c6a 100644
--- a/tests/mir-opt/building/issue_101867.main.built.after.mir
+++ b/tests/mir-opt/building/issue_101867.main.built.after.mir
@@ -27,13 +27,13 @@ fn main() -> () {
         StorageLive(_5);
         PlaceMention(_1);
         _6 = discriminant(_1);
-        switchInt(move _6) -> [1: bb4, otherwise: bb3];
+        switchInt(move _6) -> [1: bb5, otherwise: bb4];
     }
 
     bb1: {
         StorageLive(_3);
         StorageLive(_4);
-        _4 = begin_panic::<&str>(const "explicit panic") -> bb8;
+        _4 = begin_panic::<&str>(const "explicit panic") -> bb9;
     }
 
     bb2: {
@@ -43,18 +43,22 @@ fn main() -> () {
     }
 
     bb3: {
-        goto -> bb7;
+        goto -> bb8;
     }
 
     bb4: {
-        falseEdge -> [real: bb6, imaginary: bb3];
+        goto -> bb3;
     }
 
     bb5: {
-        goto -> bb3;
+        falseEdge -> [real: bb7, imaginary: bb3];
     }
 
     bb6: {
+        goto -> bb4;
+    }
+
+    bb7: {
         _5 = ((_1 as Some).0: u8);
         _0 = const ();
         StorageDead(_5);
@@ -62,12 +66,12 @@ fn main() -> () {
         return;
     }
 
-    bb7: {
+    bb8: {
         StorageDead(_5);
         goto -> bb1;
     }
 
-    bb8 (cleanup): {
+    bb9 (cleanup): {
         resume;
     }
 }
diff --git a/tests/mir-opt/building/issue_49232.main.built.after.mir b/tests/mir-opt/building/issue_49232.main.built.after.mir
index d09a1748a8b..ac7e530520a 100644
--- a/tests/mir-opt/building/issue_49232.main.built.after.mir
+++ b/tests/mir-opt/building/issue_49232.main.built.after.mir
@@ -17,7 +17,7 @@ fn main() -> () {
     }
 
     bb1: {
-        falseUnwind -> [real: bb2, unwind: bb14];
+        falseUnwind -> [real: bb2, unwind: bb15];
     }
 
     bb2: {
@@ -25,7 +25,7 @@ fn main() -> () {
         StorageLive(_3);
         _3 = const true;
         PlaceMention(_3);
-        switchInt(_3) -> [0: bb4, otherwise: bb6];
+        switchInt(_3) -> [0: bb5, otherwise: bb7];
     }
 
     bb3: {
@@ -34,45 +34,49 @@ fn main() -> () {
     }
 
     bb4: {
-        falseEdge -> [real: bb8, imaginary: bb6];
+        goto -> bb3;
     }
 
     bb5: {
-        goto -> bb3;
+        falseEdge -> [real: bb9, imaginary: bb7];
     }
 
     bb6: {
-        _0 = const ();
-        goto -> bb13;
+        goto -> bb4;
     }
 
     bb7: {
-        goto -> bb3;
+        _0 = const ();
+        goto -> bb14;
     }
 
     bb8: {
-        _2 = const 4_i32;
-        goto -> bb11;
+        goto -> bb4;
     }
 
     bb9: {
-        unreachable;
+        _2 = const 4_i32;
+        goto -> bb12;
     }
 
     bb10: {
-        goto -> bb11;
+        unreachable;
     }
 
     bb11: {
+        goto -> bb12;
+    }
+
+    bb12: {
         FakeRead(ForLet(None), _2);
         StorageDead(_3);
         StorageLive(_5);
         StorageLive(_6);
         _6 = &_2;
-        _5 = std::mem::drop::<&i32>(move _6) -> [return: bb12, unwind: bb14];
+        _5 = std::mem::drop::<&i32>(move _6) -> [return: bb13, unwind: bb15];
     }
 
-    bb12: {
+    bb13: {
         StorageDead(_6);
         StorageDead(_5);
         _1 = const ();
@@ -80,13 +84,13 @@ fn main() -> () {
         goto -> bb1;
     }
 
-    bb13: {
+    bb14: {
         StorageDead(_3);
         StorageDead(_2);
         return;
     }
 
-    bb14 (cleanup): {
+    bb15 (cleanup): {
         resume;
     }
 }
diff --git a/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir b/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir
index 3e16efe6980..395b8b82bff 100644
--- a/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir
+++ b/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir
@@ -19,180 +19,188 @@ fn test_complex() -> () {
     bb0: {
         StorageLive(_1);
         StorageLive(_2);
-        _2 = E::f() -> [return: bb1, unwind: bb34];
+        _2 = E::f() -> [return: bb1, unwind: bb36];
     }
 
     bb1: {
         PlaceMention(_2);
         _3 = discriminant(_2);
-        switchInt(move _3) -> [0: bb3, otherwise: bb2];
+        switchInt(move _3) -> [0: bb4, otherwise: bb3];
     }
 
     bb2: {
-        goto -> bb21;
+        goto -> bb22;
     }
 
     bb3: {
-        falseEdge -> [real: bb5, imaginary: bb2];
+        goto -> bb2;
     }
 
     bb4: {
-        goto -> bb2;
+        falseEdge -> [real: bb6, imaginary: bb2];
     }
 
     bb5: {
-        StorageLive(_4);
-        _4 = always_true() -> [return: bb6, unwind: bb34];
+        goto -> bb3;
     }
 
     bb6: {
-        switchInt(move _4) -> [0: bb8, otherwise: bb7];
+        StorageLive(_4);
+        _4 = always_true() -> [return: bb7, unwind: bb36];
     }
 
     bb7: {
+        switchInt(move _4) -> [0: bb9, otherwise: bb8];
+    }
+
+    bb8: {
         StorageLive(_5);
         StorageLive(_6);
         StorageLive(_7);
         _7 = Droppy(const 0_u8);
         _6 = (_7.0: u8);
         _5 = Gt(move _6, const 0_u8);
-        switchInt(move _5) -> [0: bb10, otherwise: bb9];
-    }
-
-    bb8: {
-        goto -> bb14;
+        switchInt(move _5) -> [0: bb11, otherwise: bb10];
     }
 
     bb9: {
-        drop(_7) -> [return: bb11, unwind: bb34];
+        goto -> bb15;
     }
 
     bb10: {
-        goto -> bb12;
+        drop(_7) -> [return: bb12, unwind: bb36];
     }
 
     bb11: {
-        StorageDead(_7);
-        StorageDead(_6);
-        goto -> bb18;
+        goto -> bb13;
     }
 
     bb12: {
-        drop(_7) -> [return: bb13, unwind: bb34];
+        StorageDead(_7);
+        StorageDead(_6);
+        goto -> bb19;
     }
 
     bb13: {
+        drop(_7) -> [return: bb14, unwind: bb36];
+    }
+
+    bb14: {
         StorageDead(_7);
         StorageDead(_6);
-        goto -> bb14;
+        goto -> bb15;
     }
 
-    bb14: {
+    bb15: {
         StorageLive(_8);
         StorageLive(_9);
         StorageLive(_10);
         _10 = Droppy(const 1_u8);
         _9 = (_10.0: u8);
         _8 = Gt(move _9, const 1_u8);
-        switchInt(move _8) -> [0: bb16, otherwise: bb15];
-    }
-
-    bb15: {
-        drop(_10) -> [return: bb17, unwind: bb34];
+        switchInt(move _8) -> [0: bb17, otherwise: bb16];
     }
 
     bb16: {
-        goto -> bb19;
+        drop(_10) -> [return: bb18, unwind: bb36];
     }
 
     bb17: {
-        StorageDead(_10);
-        StorageDead(_9);
-        goto -> bb18;
+        goto -> bb20;
     }
 
     bb18: {
-        _1 = const ();
-        goto -> bb22;
+        StorageDead(_10);
+        StorageDead(_9);
+        goto -> bb19;
     }
 
     bb19: {
-        drop(_10) -> [return: bb20, unwind: bb34];
+        _1 = const ();
+        goto -> bb23;
     }
 
     bb20: {
-        StorageDead(_10);
-        StorageDead(_9);
-        goto -> bb21;
+        drop(_10) -> [return: bb21, unwind: bb36];
     }
 
     bb21: {
-        _1 = const ();
+        StorageDead(_10);
+        StorageDead(_9);
         goto -> bb22;
     }
 
     bb22: {
+        _1 = const ();
+        goto -> bb23;
+    }
+
+    bb23: {
         StorageDead(_8);
         StorageDead(_5);
         StorageDead(_4);
         StorageDead(_2);
         StorageDead(_1);
         StorageLive(_11);
-        _11 = always_true() -> [return: bb23, unwind: bb34];
-    }
-
-    bb23: {
-        switchInt(move _11) -> [0: bb25, otherwise: bb24];
+        _11 = always_true() -> [return: bb24, unwind: bb36];
     }
 
     bb24: {
-        goto -> bb32;
+        switchInt(move _11) -> [0: bb26, otherwise: bb25];
     }
 
     bb25: {
-        goto -> bb26;
+        goto -> bb34;
     }
 
     bb26: {
-        StorageLive(_12);
-        _12 = E::f() -> [return: bb27, unwind: bb34];
+        goto -> bb27;
     }
 
     bb27: {
-        PlaceMention(_12);
-        _13 = discriminant(_12);
-        switchInt(move _13) -> [1: bb29, otherwise: bb28];
+        StorageLive(_12);
+        _12 = E::f() -> [return: bb28, unwind: bb36];
     }
 
     bb28: {
-        goto -> bb32;
+        PlaceMention(_12);
+        _13 = discriminant(_12);
+        switchInt(move _13) -> [1: bb31, otherwise: bb30];
     }
 
     bb29: {
-        falseEdge -> [real: bb31, imaginary: bb28];
+        goto -> bb34;
     }
 
     bb30: {
-        goto -> bb28;
+        goto -> bb29;
     }
 
     bb31: {
-        _0 = const ();
-        goto -> bb33;
+        falseEdge -> [real: bb33, imaginary: bb29];
     }
 
     bb32: {
-        _0 = const ();
-        goto -> bb33;
+        goto -> bb30;
     }
 
     bb33: {
+        _0 = const ();
+        goto -> bb35;
+    }
+
+    bb34: {
+        _0 = const ();
+        goto -> bb35;
+    }
+
+    bb35: {
         StorageDead(_11);
         StorageDead(_12);
         return;
     }
 
-    bb34 (cleanup): {
+    bb36 (cleanup): {
         resume;
     }
 }
diff --git a/tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir b/tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir
index bade0fa4b45..623dd51c358 100644
--- a/tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir
+++ b/tests/mir-opt/building/match/match_false_edges.full_tested_match.built.after.mir
@@ -28,7 +28,7 @@ fn full_tested_match() -> () {
         _2 = Option::<i32>::Some(const 42_i32);
         PlaceMention(_2);
         _4 = discriminant(_2);
-        switchInt(move _4) -> [0: bb5, 1: bb2, otherwise: bb1];
+        switchInt(move _4) -> [0: bb6, 1: bb3, otherwise: bb2];
     }
 
     bb1: {
@@ -37,39 +37,43 @@ fn full_tested_match() -> () {
     }
 
     bb2: {
-        falseEdge -> [real: bb7, imaginary: bb3];
+        goto -> bb1;
     }
 
     bb3: {
-        falseEdge -> [real: bb12, imaginary: bb5];
+        falseEdge -> [real: bb8, imaginary: bb4];
     }
 
     bb4: {
-        goto -> bb1;
+        falseEdge -> [real: bb13, imaginary: bb6];
     }
 
     bb5: {
-        _1 = (const 3_i32, const 3_i32);
-        goto -> bb13;
+        goto -> bb2;
     }
 
     bb6: {
-        goto -> bb1;
+        _1 = (const 3_i32, const 3_i32);
+        goto -> bb14;
     }
 
     bb7: {
+        goto -> bb2;
+    }
+
+    bb8: {
         StorageLive(_6);
         _6 = &((_2 as Some).0: i32);
         _3 = &fake shallow _2;
         StorageLive(_7);
-        _7 = guard() -> [return: bb8, unwind: bb16];
+        _7 = guard() -> [return: bb9, unwind: bb17];
     }
 
-    bb8: {
-        switchInt(move _7) -> [0: bb10, otherwise: bb9];
+    bb9: {
+        switchInt(move _7) -> [0: bb11, otherwise: bb10];
     }
 
-    bb9: {
+    bb10: {
         StorageDead(_7);
         FakeRead(ForMatchGuard, _3);
         FakeRead(ForGuardBinding, _6);
@@ -81,20 +85,20 @@ fn full_tested_match() -> () {
         StorageDead(_8);
         StorageDead(_5);
         StorageDead(_6);
-        goto -> bb13;
+        goto -> bb14;
     }
 
-    bb10: {
-        goto -> bb11;
+    bb11: {
+        goto -> bb12;
     }
 
-    bb11: {
+    bb12: {
         StorageDead(_7);
         StorageDead(_6);
-        goto -> bb3;
+        goto -> bb4;
     }
 
-    bb12: {
+    bb13: {
         StorageLive(_9);
         _9 = ((_2 as Some).0: i32);
         StorageLive(_10);
@@ -102,10 +106,10 @@ fn full_tested_match() -> () {
         _1 = (const 2_i32, move _10);
         StorageDead(_10);
         StorageDead(_9);
-        goto -> bb13;
+        goto -> bb14;
     }
 
-    bb13: {
+    bb14: {
         PlaceMention(_1);
         StorageDead(_2);
         StorageDead(_1);
@@ -113,16 +117,16 @@ fn full_tested_match() -> () {
         return;
     }
 
-    bb14: {
+    bb15: {
         FakeRead(ForMatchedPlace(None), _1);
         unreachable;
     }
 
-    bb15: {
-        goto -> bb14;
+    bb16: {
+        goto -> bb15;
     }
 
-    bb16 (cleanup): {
+    bb17 (cleanup): {
         resume;
     }
 }
diff --git a/tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir b/tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir
index 0d78bb8b235..3cb037bf956 100644
--- a/tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir
+++ b/tests/mir-opt/building/match/match_false_edges.full_tested_match2.built.after.mir
@@ -28,7 +28,7 @@ fn full_tested_match2() -> () {
         _2 = Option::<i32>::Some(const 42_i32);
         PlaceMention(_2);
         _4 = discriminant(_2);
-        switchInt(move _4) -> [0: bb5, 1: bb2, otherwise: bb1];
+        switchInt(move _4) -> [0: bb6, 1: bb3, otherwise: bb2];
     }
 
     bb1: {
@@ -37,10 +37,14 @@ fn full_tested_match2() -> () {
     }
 
     bb2: {
-        falseEdge -> [real: bb7, imaginary: bb5];
+        goto -> bb1;
     }
 
     bb3: {
+        falseEdge -> [real: bb8, imaginary: bb6];
+    }
+
+    bb4: {
         StorageLive(_9);
         _9 = ((_2 as Some).0: i32);
         StorageLive(_10);
@@ -48,34 +52,34 @@ fn full_tested_match2() -> () {
         _1 = (const 2_i32, move _10);
         StorageDead(_10);
         StorageDead(_9);
-        goto -> bb13;
-    }
-
-    bb4: {
-        goto -> bb1;
+        goto -> bb14;
     }
 
     bb5: {
-        falseEdge -> [real: bb12, imaginary: bb3];
+        goto -> bb2;
     }
 
     bb6: {
-        goto -> bb1;
+        falseEdge -> [real: bb13, imaginary: bb4];
     }
 
     bb7: {
+        goto -> bb2;
+    }
+
+    bb8: {
         StorageLive(_6);
         _6 = &((_2 as Some).0: i32);
         _3 = &fake shallow _2;
         StorageLive(_7);
-        _7 = guard() -> [return: bb8, unwind: bb16];
+        _7 = guard() -> [return: bb9, unwind: bb17];
     }
 
-    bb8: {
-        switchInt(move _7) -> [0: bb10, otherwise: bb9];
+    bb9: {
+        switchInt(move _7) -> [0: bb11, otherwise: bb10];
     }
 
-    bb9: {
+    bb10: {
         StorageDead(_7);
         FakeRead(ForMatchGuard, _3);
         FakeRead(ForGuardBinding, _6);
@@ -87,25 +91,25 @@ fn full_tested_match2() -> () {
         StorageDead(_8);
         StorageDead(_5);
         StorageDead(_6);
-        goto -> bb13;
+        goto -> bb14;
     }
 
-    bb10: {
-        goto -> bb11;
+    bb11: {
+        goto -> bb12;
     }
 
-    bb11: {
+    bb12: {
         StorageDead(_7);
         StorageDead(_6);
-        falseEdge -> [real: bb3, imaginary: bb5];
+        falseEdge -> [real: bb4, imaginary: bb6];
     }
 
-    bb12: {
+    bb13: {
         _1 = (const 3_i32, const 3_i32);
-        goto -> bb13;
+        goto -> bb14;
     }
 
-    bb13: {
+    bb14: {
         PlaceMention(_1);
         StorageDead(_2);
         StorageDead(_1);
@@ -113,16 +117,16 @@ fn full_tested_match2() -> () {
         return;
     }
 
-    bb14: {
+    bb15: {
         FakeRead(ForMatchedPlace(None), _1);
         unreachable;
     }
 
-    bb15: {
-        goto -> bb14;
+    bb16: {
+        goto -> bb15;
     }
 
-    bb16 (cleanup): {
+    bb17 (cleanup): {
         resume;
     }
 }
diff --git a/tests/mir-opt/building/match/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match/match_false_edges.main.built.after.mir
index ebb75ae141a..134517ad2ae 100644
--- a/tests/mir-opt/building/match/match_false_edges.main.built.after.mir
+++ b/tests/mir-opt/building/match/match_false_edges.main.built.after.mir
@@ -38,8 +38,8 @@ fn main() -> () {
         StorageLive(_2);
         _2 = Option::<i32>::Some(const 1_i32);
         PlaceMention(_2);
-        _5 = discriminant(_2);
-        switchInt(move _5) -> [1: bb8, otherwise: bb2];
+        _4 = discriminant(_2);
+        switchInt(move _4) -> [1: bb3, otherwise: bb2];
     }
 
     bb1: {
@@ -48,40 +48,40 @@ fn main() -> () {
     }
 
     bb2: {
-        falseEdge -> [real: bb15, imaginary: bb3];
+        falseEdge -> [real: bb15, imaginary: bb5];
     }
 
     bb3: {
-        _4 = discriminant(_2);
-        switchInt(move _4) -> [1: bb6, otherwise: bb4];
+        falseEdge -> [real: bb10, imaginary: bb2];
     }
 
     bb4: {
-        StorageLive(_14);
-        _14 = _2;
-        _1 = const 4_i32;
-        StorageDead(_14);
-        goto -> bb21;
+        goto -> bb2;
     }
 
     bb5: {
-        goto -> bb1;
+        _5 = discriminant(_2);
+        switchInt(move _5) -> [1: bb7, otherwise: bb6];
     }
 
     bb6: {
-        falseEdge -> [real: bb16, imaginary: bb4];
+        StorageLive(_14);
+        _14 = _2;
+        _1 = const 4_i32;
+        StorageDead(_14);
+        goto -> bb21;
     }
 
     bb7: {
-        goto -> bb4;
+        falseEdge -> [real: bb16, imaginary: bb6];
     }
 
     bb8: {
-        falseEdge -> [real: bb10, imaginary: bb2];
+        goto -> bb6;
     }
 
     bb9: {
-        goto -> bb2;
+        goto -> bb1;
     }
 
     bb10: {
@@ -115,7 +115,7 @@ fn main() -> () {
     bb14: {
         StorageDead(_8);
         StorageDead(_7);
-        falseEdge -> [real: bb9, imaginary: bb2];
+        falseEdge -> [real: bb4, imaginary: bb2];
     }
 
     bb15: {
@@ -161,7 +161,7 @@ fn main() -> () {
         StorageDead(_13);
         StorageDead(_12);
         StorageDead(_11);
-        falseEdge -> [real: bb7, imaginary: bb4];
+        falseEdge -> [real: bb8, imaginary: bb6];
     }
 
     bb21: {
diff --git a/tests/mir-opt/building/match/simple_match.match_bool.built.after.mir b/tests/mir-opt/building/match/simple_match.match_bool.built.after.mir
index faa2456fd10..81b5ce304d0 100644
--- a/tests/mir-opt/building/match/simple_match.match_bool.built.after.mir
+++ b/tests/mir-opt/building/match/simple_match.match_bool.built.after.mir
@@ -6,7 +6,7 @@ fn match_bool(_1: bool) -> usize {
 
     bb0: {
         PlaceMention(_1);
-        switchInt(_1) -> [0: bb2, otherwise: bb4];
+        switchInt(_1) -> [0: bb2, otherwise: bb3];
     }
 
     bb1: {
@@ -20,15 +20,15 @@ fn match_bool(_1: bool) -> usize {
     }
 
     bb3: {
-        goto -> bb1;
+        falseEdge -> [real: bb6, imaginary: bb2];
     }
 
     bb4: {
-        falseEdge -> [real: bb6, imaginary: bb2];
+        goto -> bb2;
     }
 
     bb5: {
-        goto -> bb2;
+        goto -> bb1;
     }
 
     bb6: {
diff --git a/tests/mir-opt/building/match/simple_match.match_enum.built.after.mir b/tests/mir-opt/building/match/simple_match.match_enum.built.after.mir
index 905aa19da70..c2ea5bd441c 100644
--- a/tests/mir-opt/building/match/simple_match.match_enum.built.after.mir
+++ b/tests/mir-opt/building/match/simple_match.match_enum.built.after.mir
@@ -8,7 +8,7 @@ fn match_enum(_1: E1) -> bool {
     bb0: {
         PlaceMention(_1);
         _2 = discriminant(_1);
-        switchInt(move _2) -> [0: bb3, 1: bb5, 2: bb7, otherwise: bb2];
+        switchInt(move _2) -> [0: bb4, 1: bb6, 2: bb8, otherwise: bb3];
     }
 
     bb1: {
@@ -21,40 +21,44 @@ fn match_enum(_1: E1) -> bool {
     }
 
     bb3: {
-        goto -> bb9;
+        goto -> bb2;
     }
 
     bb4: {
-        goto -> bb2;
+        goto -> bb10;
     }
 
     bb5: {
-        goto -> bb9;
+        goto -> bb3;
     }
 
     bb6: {
-        goto -> bb2;
+        goto -> bb10;
     }
 
     bb7: {
-        _0 = const false;
-        goto -> bb11;
+        goto -> bb3;
     }
 
     bb8: {
-        goto -> bb2;
+        _0 = const false;
+        goto -> bb12;
     }
 
     bb9: {
-        falseEdge -> [real: bb10, imaginary: bb7];
+        goto -> bb3;
     }
 
     bb10: {
-        _0 = const true;
-        goto -> bb11;
+        falseEdge -> [real: bb11, imaginary: bb8];
     }
 
     bb11: {
+        _0 = const true;
+        goto -> bb12;
+    }
+
+    bb12: {
         return;
     }
 }
diff --git a/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir
index 060cd6132e3..2b5dbacc2d9 100644
--- a/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir
+++ b/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir
@@ -23,52 +23,52 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
         StorageDead(_5);
         StorageDead(_4);
         PlaceMention(_3);
-        _9 = <str as PartialEq>::eq((_3.0: &str), const "a") -> [return: bb11, unwind: bb19];
+        _9 = <str as PartialEq>::eq((_3.0: &str), const "a") -> [return: bb9, unwind: bb19];
     }
 
     bb1: {
-        switchInt((_3.1: bool)) -> [0: bb2, otherwise: bb3];
+        switchInt((_3.1: bool)) -> [0: bb10, otherwise: bb11];
     }
 
     bb2: {
-        _0 = const 5_u32;
-        goto -> bb18;
+        falseEdge -> [real: bb12, imaginary: bb5];
     }
 
     bb3: {
-        falseEdge -> [real: bb17, imaginary: bb2];
+        switchInt((_3.1: bool)) -> [0: bb1, otherwise: bb4];
     }
 
     bb4: {
-        falseEdge -> [real: bb12, imaginary: bb7];
+        falseEdge -> [real: bb16, imaginary: bb1];
     }
 
     bb5: {
-        switchInt((_3.1: bool)) -> [0: bb1, otherwise: bb6];
+        _8 = <str as PartialEq>::eq((_3.0: &str), const "b") -> [return: bb8, unwind: bb19];
     }
 
     bb6: {
-        falseEdge -> [real: bb16, imaginary: bb1];
+        switchInt((_3.1: bool)) -> [0: bb1, otherwise: bb7];
     }
 
     bb7: {
-        _8 = <str as PartialEq>::eq((_3.0: &str), const "b") -> [return: bb10, unwind: bb19];
+        falseEdge -> [real: bb15, imaginary: bb3];
     }
 
     bb8: {
-        switchInt((_3.1: bool)) -> [0: bb1, otherwise: bb9];
+        switchInt(move _8) -> [0: bb1, otherwise: bb6];
     }
 
     bb9: {
-        falseEdge -> [real: bb15, imaginary: bb5];
+        switchInt(move _9) -> [0: bb5, otherwise: bb2];
     }
 
     bb10: {
-        switchInt(move _8) -> [0: bb1, otherwise: bb8];
+        _0 = const 5_u32;
+        goto -> bb18;
     }
 
     bb11: {
-        switchInt(move _9) -> [0: bb7, otherwise: bb4];
+        falseEdge -> [real: bb17, imaginary: bb10];
     }
 
     bb12: {
@@ -89,7 +89,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
 
     bb14: {
         StorageDead(_10);
-        falseEdge -> [real: bb5, imaginary: bb7];
+        falseEdge -> [real: bb3, imaginary: bb5];
     }
 
     bb15: {
diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff
index 938b9bb14ad..3a5762e4f3d 100644
--- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff
+++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff
@@ -22,59 +22,55 @@
   
       bb1: {
           StorageDead(_3);
-          _7 = Len((*_2));
-          _8 = const 4_usize;
-          _9 = Ge(move _7, move _8);
--         switchInt(move _9) -> [0: bb2, otherwise: bb7];
-+         switchInt(move _9) -> [0: bb2, otherwise: bb6];
+          _4 = Len((*_2));
+          _5 = const 4_usize;
+          _6 = Ge(move _4, move _5);
+          switchInt(move _6) -> [0: bb2, otherwise: bb3];
       }
   
       bb2: {
-          _4 = Len((*_2));
-          _5 = const 3_usize;
-          _6 = Ge(move _4, move _5);
--         switchInt(move _6) -> [0: bb3, otherwise: bb4];
-+         switchInt(move _6) -> [0: bb10, otherwise: bb3];
+          _7 = Len((*_2));
+          _8 = const 3_usize;
+          _9 = Ge(move _7, move _8);
+-         switchInt(move _9) -> [0: bb7, otherwise: bb8];
++         switchInt(move _9) -> [0: bb10, otherwise: bb7];
       }
   
       bb3: {
--         _0 = const false;
--         goto -> bb14;
-+         switchInt((*_2)[0 of 3]) -> [47: bb4, otherwise: bb10];
+          switchInt((*_2)[0 of 4]) -> [47: bb4, otherwise: bb2];
       }
   
       bb4: {
--         switchInt((*_2)[0 of 3]) -> [47: bb5, otherwise: bb3];
-+         switchInt((*_2)[1 of 3]) -> [47: bb5, otherwise: bb10];
+          switchInt((*_2)[1 of 4]) -> [47: bb5, otherwise: bb2];
       }
   
       bb5: {
--         switchInt((*_2)[1 of 3]) -> [47: bb6, otherwise: bb3];
-+         switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10];
+          switchInt((*_2)[2 of 4]) -> [47: bb6, otherwise: bb2];
       }
   
       bb6: {
--         switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb3];
-+         switchInt((*_2)[0 of 4]) -> [47: bb7, otherwise: bb2];
+-         switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
++         switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2];
       }
   
       bb7: {
--         switchInt((*_2)[0 of 4]) -> [47: bb8, otherwise: bb2];
-+         switchInt((*_2)[1 of 4]) -> [47: bb8, otherwise: bb2];
+-         _0 = const false;
+-         goto -> bb14;
++         switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10];
       }
   
       bb8: {
--         switchInt((*_2)[1 of 4]) -> [47: bb9, otherwise: bb2];
-+         switchInt((*_2)[2 of 4]) -> [47: bb9, otherwise: bb2];
+-         switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7];
++         switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10];
       }
   
       bb9: {
--         switchInt((*_2)[2 of 4]) -> [47: bb10, otherwise: bb2];
-+         switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2];
+-         switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7];
++         switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10];
       }
   
       bb10: {
--         switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
+-         switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb7];
 -     }
 - 
 -     bb11: {
diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff
index ce89694076b..21b197d2f27 100644
--- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff
+++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff
@@ -22,59 +22,55 @@
   
       bb1: {
           StorageDead(_3);
-          _7 = Len((*_2));
-          _8 = const 4_usize;
-          _9 = Ge(move _7, move _8);
--         switchInt(move _9) -> [0: bb2, otherwise: bb7];
-+         switchInt(move _9) -> [0: bb2, otherwise: bb6];
+          _4 = Len((*_2));
+          _5 = const 4_usize;
+          _6 = Ge(move _4, move _5);
+          switchInt(move _6) -> [0: bb2, otherwise: bb3];
       }
   
       bb2: {
-          _4 = Len((*_2));
-          _5 = const 3_usize;
-          _6 = Ge(move _4, move _5);
--         switchInt(move _6) -> [0: bb3, otherwise: bb4];
-+         switchInt(move _6) -> [0: bb10, otherwise: bb3];
+          _7 = Len((*_2));
+          _8 = const 3_usize;
+          _9 = Ge(move _7, move _8);
+-         switchInt(move _9) -> [0: bb7, otherwise: bb8];
++         switchInt(move _9) -> [0: bb10, otherwise: bb7];
       }
   
       bb3: {
--         _0 = const false;
--         goto -> bb14;
-+         switchInt((*_2)[0 of 3]) -> [47: bb4, otherwise: bb10];
+          switchInt((*_2)[0 of 4]) -> [47: bb4, otherwise: bb2];
       }
   
       bb4: {
--         switchInt((*_2)[0 of 3]) -> [47: bb5, otherwise: bb3];
-+         switchInt((*_2)[1 of 3]) -> [47: bb5, otherwise: bb10];
+          switchInt((*_2)[1 of 4]) -> [47: bb5, otherwise: bb2];
       }
   
       bb5: {
--         switchInt((*_2)[1 of 3]) -> [47: bb6, otherwise: bb3];
-+         switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10];
+          switchInt((*_2)[2 of 4]) -> [47: bb6, otherwise: bb2];
       }
   
       bb6: {
--         switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb3];
-+         switchInt((*_2)[0 of 4]) -> [47: bb7, otherwise: bb2];
+-         switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
++         switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2];
       }
   
       bb7: {
--         switchInt((*_2)[0 of 4]) -> [47: bb8, otherwise: bb2];
-+         switchInt((*_2)[1 of 4]) -> [47: bb8, otherwise: bb2];
+-         _0 = const false;
+-         goto -> bb14;
++         switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10];
       }
   
       bb8: {
--         switchInt((*_2)[1 of 4]) -> [47: bb9, otherwise: bb2];
-+         switchInt((*_2)[2 of 4]) -> [47: bb9, otherwise: bb2];
+-         switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7];
++         switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10];
       }
   
       bb9: {
--         switchInt((*_2)[2 of 4]) -> [47: bb10, otherwise: bb2];
-+         switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2];
+-         switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7];
++         switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10];
       }
   
       bb10: {
--         switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
+-         switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb7];
 -     }
 - 
 -     bb11: {
diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff
index 209f0d09c29..4f29e5244d7 100644
--- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff
+++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff
@@ -32,25 +32,33 @@
   
       bb0: {
           PlaceMention(_2);
--         switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1];
+-         switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1];
 +         switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1];
       }
   
       bb1: {
--         switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2];
+-         switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3];
 +         switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2];
       }
   
       bb2: {
--         switchInt((_2.0: bool)) -> [0: bb4, otherwise: bb3];
+-         falseEdge -> [real: bb8, imaginary: bb1];
 +         switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17];
       }
   
       bb3: {
--         falseEdge -> [real: bb20, imaginary: bb4];
+-         switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb5];
 -     }
 - 
 -     bb4: {
+-         falseEdge -> [real: bb13, imaginary: bb3];
+-     }
+- 
+-     bb5: {
+-         falseEdge -> [real: bb20, imaginary: bb6];
+-     }
+- 
+-     bb6: {
           StorageLive(_15);
           _15 = (_2.1: bool);
           StorageLive(_16);
@@ -59,14 +67,6 @@
 +         goto -> bb16;
       }
   
--     bb5: {
--         falseEdge -> [real: bb13, imaginary: bb2];
--     }
-- 
--     bb6: {
--         falseEdge -> [real: bb8, imaginary: bb1];
--     }
-- 
 -     bb7: {
 +     bb4: {
           _0 = const 1_i32;
@@ -184,7 +184,7 @@
           StorageDead(_12);
           StorageDead(_8);
           StorageDead(_6);
--         falseEdge -> [real: bb2, imaginary: bb2];
+-         falseEdge -> [real: bb3, imaginary: bb3];
 +         goto -> bb2;
       }
   
diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff
index 209f0d09c29..4f29e5244d7 100644
--- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff
+++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff
@@ -32,25 +32,33 @@
   
       bb0: {
           PlaceMention(_2);
--         switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1];
+-         switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1];
 +         switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1];
       }
   
       bb1: {
--         switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2];
+-         switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3];
 +         switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2];
       }
   
       bb2: {
--         switchInt((_2.0: bool)) -> [0: bb4, otherwise: bb3];
+-         falseEdge -> [real: bb8, imaginary: bb1];
 +         switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17];
       }
   
       bb3: {
--         falseEdge -> [real: bb20, imaginary: bb4];
+-         switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb5];
 -     }
 - 
 -     bb4: {
+-         falseEdge -> [real: bb13, imaginary: bb3];
+-     }
+- 
+-     bb5: {
+-         falseEdge -> [real: bb20, imaginary: bb6];
+-     }
+- 
+-     bb6: {
           StorageLive(_15);
           _15 = (_2.1: bool);
           StorageLive(_16);
@@ -59,14 +67,6 @@
 +         goto -> bb16;
       }
   
--     bb5: {
--         falseEdge -> [real: bb13, imaginary: bb2];
--     }
-- 
--     bb6: {
--         falseEdge -> [real: bb8, imaginary: bb1];
--     }
-- 
 -     bb7: {
 +     bb4: {
           _0 = const 1_i32;
@@ -184,7 +184,7 @@
           StorageDead(_12);
           StorageDead(_8);
           StorageDead(_6);
--         falseEdge -> [real: bb2, imaginary: bb2];
+-         falseEdge -> [real: bb3, imaginary: bb3];
 +         goto -> bb2;
       }
   
diff --git a/tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir b/tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir
index 56edd38a6da..775bc8afd7b 100644
--- a/tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir
+++ b/tests/mir-opt/or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir
@@ -18,7 +18,7 @@ fn shortcut_second_or() -> () {
         _1 = (move _2, const 0_i32);
         StorageDead(_2);
         PlaceMention(_1);
-        switchInt(((_1.0: (i32, i32)).0: i32)) -> [0: bb4, otherwise: bb2];
+        switchInt(((_1.0: (i32, i32)).0: i32)) -> [0: bb3, otherwise: bb2];
     }
 
     bb1: {
@@ -27,15 +27,15 @@ fn shortcut_second_or() -> () {
     }
 
     bb2: {
-        switchInt(((_1.0: (i32, i32)).1: i32)) -> [1: bb3, otherwise: bb1];
+        switchInt(((_1.0: (i32, i32)).1: i32)) -> [1: bb4, otherwise: bb1];
     }
 
     bb3: {
-        switchInt((_1.1: i32)) -> [2: bb7, 3: bb8, otherwise: bb1];
+        switchInt((_1.1: i32)) -> [2: bb5, 3: bb6, otherwise: bb1];
     }
 
     bb4: {
-        switchInt((_1.1: i32)) -> [2: bb5, 3: bb6, otherwise: bb1];
+        switchInt((_1.1: i32)) -> [2: bb7, 3: bb8, otherwise: bb1];
     }
 
     bb5: {