summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir135
-rw-r--r--tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir114
-rw-r--r--tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir82
-rw-r--r--tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir89
-rw-r--r--tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir47
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.mir15
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir124
7 files changed, 334 insertions, 272 deletions
diff --git a/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir
index 837962a6aa3..26ce7fda4ed 100644
--- a/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir
@@ -7,26 +7,26 @@ fn naive(_1: &Blueprint, _2: &Blueprint) -> bool {
     let mut _3: u32;                     // in scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22
     let mut _4: u32;                     // in scope 0 at $DIR/chained_comparison.rs:+1:26: +1:42
     let mut _5: bool;                    // in scope 0 at $DIR/chained_comparison.rs:+1:5: +1:43
-    let mut _6: bool;                    // in scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
-    let mut _7: u32;                     // in scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22
-    let mut _8: u32;                     // in scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35
-    let mut _9: bool;                    // in scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36
-    let mut _10: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
-    let mut _11: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29
-    let mut _12: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49
-    let mut _13: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50
-    let mut _14: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
-    let mut _15: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26
-    let mut _16: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43
-    let mut _17: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44
+    let mut _6: u32;                     // in scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22
+    let mut _7: u32;                     // in scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35
+    let mut _8: bool;                    // in scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36
+    let mut _9: bool;                    // in scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
+    let mut _10: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29
+    let mut _11: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49
+    let mut _12: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50
+    let mut _13: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
+    let mut _14: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26
+    let mut _15: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43
+    let mut _16: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44
+    let mut _17: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
     let mut _18: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+5:13: +5:22
     let mut _19: u32;                    // in scope 0 at $DIR/chained_comparison.rs:+5:26: +5:35
     let mut _20: bool;                   // in scope 0 at $DIR/chained_comparison.rs:+5:12: +5:36
 
     bb0: {
-        StorageLive(_14);                // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
-        StorageLive(_10);                // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
-        StorageLive(_6);                 // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
+        StorageLive(_17);                // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
+        StorageLive(_13);                // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
+        StorageLive(_9);                 // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
         StorageLive(_5);                 // scope 0 at $DIR/chained_comparison.rs:+1:5: +1:43
         StorageLive(_3);                 // scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22
         _3 = ((*_1).0: u32);             // scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22
@@ -39,83 +39,74 @@ fn naive(_1: &Blueprint, _2: &Blueprint) -> bool {
     }
 
     bb1: {
-        _6 = const false;                // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
+        StorageDead(_8);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
+        StorageDead(_5);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
         goto -> bb3;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
     }
 
     bb2: {
-        StorageLive(_9);                 // scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36
-        StorageLive(_7);                 // scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22
-        _7 = ((*_1).1: u32);             // scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22
-        StorageLive(_8);                 // scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35
-        _8 = ((*_2).1: u32);             // scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35
-        _9 = Eq(move _7, move _8);       // scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36
-        StorageDead(_8);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
+        StorageLive(_8);                 // scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36
+        StorageLive(_6);                 // scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22
+        _6 = ((*_1).1: u32);             // scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22
+        StorageLive(_7);                 // scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35
+        _7 = ((*_2).1: u32);             // scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35
+        _8 = Eq(move _6, move _7);       // scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36
         StorageDead(_7);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
-        _6 = move _9;                    // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
-        goto -> bb3;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
+        StorageDead(_6);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
+        _9 = move _8;                    // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36
+        StorageDead(_8);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
+        StorageDead(_5);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
+        switchInt(move _9) -> [0: bb3, otherwise: bb4]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
     }
 
     bb3: {
-        StorageDead(_9);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
-        StorageDead(_5);                 // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36
-        switchInt(move _6) -> [0: bb4, otherwise: bb5]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
+        StorageDead(_12);                // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
+        StorageDead(_9);                 // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
+        goto -> bb5;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
     }
 
     bb4: {
-        _10 = const false;               // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
-        goto -> bb6;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
+        StorageLive(_12);                // scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50
+        StorageLive(_10);                // scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29
+        _10 = ((*_1).2: u32);            // scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29
+        StorageLive(_11);                // scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49
+        _11 = ((*_2).2: u32);            // scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49
+        _12 = Eq(move _10, move _11);    // scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50
+        StorageDead(_11);                // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
+        StorageDead(_10);                // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
+        _13 = move _12;                  // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
+        StorageDead(_12);                // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
+        StorageDead(_9);                 // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
+        switchInt(move _13) -> [0: bb5, otherwise: bb6]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
     }
 
     bb5: {
-        StorageLive(_13);                // scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50
-        StorageLive(_11);                // scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29
-        _11 = ((*_1).2: u32);            // scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29
-        StorageLive(_12);                // scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49
-        _12 = ((*_2).2: u32);            // scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49
-        _13 = Eq(move _11, move _12);    // scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50
-        StorageDead(_12);                // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
-        StorageDead(_11);                // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
-        _10 = move _13;                  // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
-        goto -> bb6;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50
+        StorageDead(_16);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
+        StorageDead(_13);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
+        goto -> bb7;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
     }
 
     bb6: {
-        StorageDead(_13);                // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
-        StorageDead(_6);                 // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50
-        switchInt(move _10) -> [0: bb7, otherwise: bb8]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
-    }
-
-    bb7: {
-        _14 = const false;               // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
-        goto -> bb9;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
-    }
-
-    bb8: {
-        StorageLive(_17);                // scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44
-        StorageLive(_15);                // scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26
-        _15 = ((*_1).3: u32);            // scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26
-        StorageLive(_16);                // scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43
-        _16 = ((*_2).3: u32);            // scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43
-        _17 = Eq(move _15, move _16);    // scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44
-        StorageDead(_16);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
+        StorageLive(_16);                // scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44
+        StorageLive(_14);                // scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26
+        _14 = ((*_1).3: u32);            // scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26
+        StorageLive(_15);                // scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43
+        _15 = ((*_2).3: u32);            // scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43
+        _16 = Eq(move _14, move _15);    // scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44
         StorageDead(_15);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
-        _14 = move _17;                  // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
-        goto -> bb9;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
-    }
-
-    bb9: {
-        StorageDead(_17);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
-        StorageDead(_10);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
-        switchInt(move _14) -> [0: bb10, otherwise: bb11]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36
+        StorageDead(_14);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
+        _17 = move _16;                  // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44
+        StorageDead(_16);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
+        StorageDead(_13);                // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44
+        switchInt(move _17) -> [0: bb7, otherwise: bb8]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36
     }
 
-    bb10: {
+    bb7: {
         _0 = const false;                // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36
-        goto -> bb12;                    // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36
+        goto -> bb9;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36
     }
 
-    bb11: {
+    bb8: {
         StorageLive(_20);                // scope 0 at $DIR/chained_comparison.rs:+5:12: +5:36
         StorageLive(_18);                // scope 0 at $DIR/chained_comparison.rs:+5:13: +5:22
         _18 = ((*_1).4: u32);            // scope 0 at $DIR/chained_comparison.rs:+5:13: +5:22
@@ -125,12 +116,12 @@ fn naive(_1: &Blueprint, _2: &Blueprint) -> bool {
         StorageDead(_19);                // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36
         StorageDead(_18);                // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36
         _0 = move _20;                   // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36
-        goto -> bb12;                    // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36
+        goto -> bb9;                     // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36
     }
 
-    bb12: {
+    bb9: {
         StorageDead(_20);                // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36
-        StorageDead(_14);                // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36
+        StorageDead(_17);                // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36
         return;                          // scope 0 at $DIR/chained_comparison.rs:+6:2: +6:2
     }
 }
diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir
index 369a299b7bc..55945bbc8fc 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir
@@ -7,19 +7,17 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
     scope 1 (inlined core::num::<impl u32>::checked_shl) { // at $DIR/checked_ops.rs:16:7: 16:23
         debug self => _1;                // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
         debug rhs => _2;                 // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        let mut _13: (u32, bool);        // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        let _14: u32;                    // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        let _15: bool;                   // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        let mut _16: bool;               // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        let mut _11: u32;                // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        let mut _12: bool;               // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL
         scope 2 {
-            debug a => _14;              // in scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-            debug b => _15;              // in scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+            debug a => _11;              // in scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+            debug b => _10;              // in scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
         }
         scope 3 (inlined core::num::<impl u32>::overflowing_shl) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
             debug self => _1;            // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
             debug rhs => _2;             // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-            let mut _11: u32;            // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-            let mut _12: bool;           // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+            let mut _9: u32;             // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+            let mut _10: bool;           // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
             scope 4 (inlined core::num::<impl u32>::wrapping_shl) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
                 debug self => _1;        // in scope 4 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
                 debug rhs => _2;         // in scope 4 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
@@ -29,39 +27,37 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
                     scope 6 (inlined core::num::<impl u32>::unchecked_shl) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
                         debug self => _1; // in scope 6 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
                         debug rhs => _4; // in scope 6 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-                        let mut _5: (u32,); // in scope 6 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-                        let mut _6: u32; // in scope 6 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-                        let mut _10: u32; // in scope 6 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+                        let mut _8: u32; // in scope 6 at $SRC_DIR/core/src/num/mod.rs:LL:COL
                         scope 7 {
                             scope 8 (inlined core::num::<impl u32>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
-                                debug x => _6; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-                                let mut _7: std::result::Result<u32, std::convert::Infallible>; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-                                let mut _9: std::option::Option<u32>; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+                                debug x => _4; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+                                let mut _5: std::result::Result<u32, std::convert::Infallible>; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+                                let mut _7: std::option::Option<u32>; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL
                                 scope 9 {
                                     scope 10 (inlined <u32 as TryInto<u32>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
-                                        debug self => _6; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
+                                        debug self => _4; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
                                         scope 11 (inlined <u32 as TryFrom<u32>>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-                                            debug value => _6; // in scope 11 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
+                                            debug value => _4; // in scope 11 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
                                             scope 21 (inlined <u32 as Into<u32>>::into) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-                                                debug self => _6; // in scope 21 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
+                                                debug self => _4; // in scope 21 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
                                                 scope 22 (inlined <u32 as From<u32>>::from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-                                                    debug t => _6; // in scope 22 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
+                                                    debug t => _4; // in scope 22 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
                                                 }
                                             }
                                         }
                                     }
                                     scope 12 (inlined Result::<u32, Infallible>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
-                                        debug self => _7; // in scope 12 at $SRC_DIR/core/src/result.rs:LL:COL
-                                        let _8: u32; // in scope 12 at $SRC_DIR/core/src/result.rs:LL:COL
+                                        debug self => _5; // in scope 12 at $SRC_DIR/core/src/result.rs:LL:COL
+                                        let _6: u32; // in scope 12 at $SRC_DIR/core/src/result.rs:LL:COL
                                         scope 13 {
-                                            debug x => _8; // in scope 13 at $SRC_DIR/core/src/result.rs:LL:COL
+                                            debug x => _6; // in scope 13 at $SRC_DIR/core/src/result.rs:LL:COL
                                         }
                                     }
                                     scope 14 (inlined #[track_caller] Option::<u32>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL
-                                        debug self => _9; // in scope 14 at $SRC_DIR/core/src/option.rs:LL:COL
-                                        let mut _17: &std::option::Option<u32>; // in scope 14 at $SRC_DIR/core/src/option.rs:LL:COL
+                                        debug self => _7; // in scope 14 at $SRC_DIR/core/src/option.rs:LL:COL
+                                        let mut _13: &std::option::Option<u32>; // in scope 14 at $SRC_DIR/core/src/option.rs:LL:COL
                                         scope 15 {
-                                            debug val => _10; // in scope 15 at $SRC_DIR/core/src/option.rs:LL:COL
+                                            debug val => _8; // in scope 15 at $SRC_DIR/core/src/option.rs:LL:COL
                                         }
                                         scope 16 {
                                             scope 18 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL
@@ -72,7 +68,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
                                             }
                                         }
                                         scope 17 (inlined Option::<u32>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL
-                                            debug self => _17; // in scope 17 at $SRC_DIR/core/src/option.rs:LL:COL
+                                            debug self => _13; // in scope 17 at $SRC_DIR/core/src/option.rs:LL:COL
                                         }
                                     }
                                 }
@@ -85,64 +81,52 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
     }
 
     bb0: {
-        StorageLive(_14);                // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23
-        StorageLive(_15);                // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23
-        StorageLive(_13);                // scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageLive(_11);                // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageLive(_6);                 // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageLive(_4);                 // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        StorageLive(_10);                // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23
+        StorageLive(_11);                // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23
+        StorageLive(_9);                 // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        StorageLive(_4);                 // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
         StorageLive(_3);                 // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
         _3 = const 31_u32;               // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
         _4 = BitAnd(_2, move _3);        // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
         StorageDead(_3);                 // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageLive(_10);                // scope 7 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        StorageLive(_5);                 // scope 7 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        _5 = (_4,);                      // scope 7 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        _6 = move (_5.0: u32);           // scope 7 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        StorageLive(_9);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        StorageLive(_8);                 // scope 7 at $SRC_DIR/core/src/num/mod.rs:LL:COL
         StorageLive(_7);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        _7 = Result::<u32, Infallible>::Ok(_6); // scope 11 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
-        StorageLive(_8);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        _8 = move ((_7 as Ok).0: u32);   // scope 12 at $SRC_DIR/core/src/result.rs:LL:COL
-        _9 = Option::<u32>::Some(move _8); // scope 13 at $SRC_DIR/core/src/result.rs:LL:COL
-        StorageDead(_8);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        StorageLive(_5);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        _5 = Result::<u32, Infallible>::Ok(_4); // scope 11 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
+        StorageLive(_6);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        _6 = move ((_5 as Ok).0: u32);   // scope 12 at $SRC_DIR/core/src/result.rs:LL:COL
+        _7 = Option::<u32>::Some(move _6); // scope 13 at $SRC_DIR/core/src/result.rs:LL:COL
+        StorageDead(_6);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        StorageDead(_5);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        StorageLive(_13);                // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        _8 = move ((_7 as Some).0: u32); // scope 14 at $SRC_DIR/core/src/option.rs:LL:COL
+        StorageDead(_13);                // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
         StorageDead(_7);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        StorageLive(_17);                // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        _10 = move ((_9 as Some).0: u32); // scope 14 at $SRC_DIR/core/src/option.rs:LL:COL
-        StorageDead(_17);                // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        StorageDead(_9);                 // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        StorageDead(_5);                 // scope 7 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        _11 = unchecked_shl::<u32>(_1, move _10) -> [return: bb1, unwind unreachable]; // scope 7 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        _9 = unchecked_shl::<u32>(_1, move _8) -> [return: bb1, unwind unreachable]; // scope 7 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
                                          // mir::Constant
                                          // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
                                          // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32, u32) -> u32 {unchecked_shl::<u32>}, val: Value(<ZST>) }
     }
 
     bb1: {
-        StorageDead(_10);                // scope 7 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageDead(_4);                 // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageDead(_6);                 // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageLive(_12);                // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        _12 = Ge(_2, const _);           // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        _13 = (move _11, move _12);      // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageDead(_12);                // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageDead(_11);                // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        _14 = (_13.0: u32);              // scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        _15 = (_13.1: bool);             // scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageDead(_13);                // scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageLive(_16);                // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
-        _16 = unlikely(_15) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        StorageDead(_8);                 // scope 7 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        StorageDead(_4);                 // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        _10 = Ge(_2, const _);           // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        _11 = move _9;                   // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        StorageDead(_9);                 // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        StorageLive(_12);                // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        _12 = unlikely(_10) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
                                          // mir::Constant
                                          // + span: $SRC_DIR/core/src/num/mod.rs:LL:COL
                                          // + literal: Const { ty: extern "rust-intrinsic" fn(bool) -> bool {unlikely}, val: Value(<ZST>) }
     }
 
     bb2: {
-        switchInt(move _16) -> [0: bb3, otherwise: bb4]; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
+        switchInt(move _12) -> [0: bb3, otherwise: bb4]; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL
     }
 
     bb3: {
-        _0 = Option::<u32>::Some(_14);   // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        _0 = Option::<u32>::Some(_11);   // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
         goto -> bb5;                     // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
     }
 
@@ -152,9 +136,9 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
     }
 
     bb5: {
-        StorageDead(_16);                // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
-        StorageDead(_15);                // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23
-        StorageDead(_14);                // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23
+        StorageDead(_12);                // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
+        StorageDead(_11);                // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23
+        StorageDead(_10);                // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23
         return;                          // scope 0 at $DIR/checked_ops.rs:+2:2: +2:2
     }
 }
diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir
index 12245ccf000..a5002cd6afa 100644
--- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir
@@ -7,17 +7,30 @@ fn int_range(_1: usize, _2: usize) -> () {
     let mut _3: std::ops::Range<usize>;  // in scope 0 at $DIR/loops.rs:+1:14: +1:24
     let mut _4: std::ops::Range<usize>;  // in scope 0 at $DIR/loops.rs:+1:14: +1:24
     let mut _5: &mut std::ops::Range<usize>; // in scope 0 at $DIR/loops.rs:+1:14: +1:24
-    let mut _6: std::option::Option<usize>; // in scope 0 at $DIR/loops.rs:+1:14: +1:24
-    let mut _7: isize;                   // in scope 0 at $DIR/loops.rs:+1:5: +3:6
-    let _9: ();                          // in scope 0 at $DIR/loops.rs:+1:14: +1:24
+    let mut _9: std::option::Option<usize>; // in scope 0 at $DIR/loops.rs:+1:14: +1:24
+    let mut _12: isize;                  // in scope 0 at $DIR/loops.rs:+1:5: +3:6
+    let _14: ();                         // in scope 0 at $DIR/loops.rs:+1:14: +1:24
     scope 1 {
         debug iter => _4;                // in scope 1 at $DIR/loops.rs:+1:14: +1:24
-        let _8: usize;                   // in scope 1 at $DIR/loops.rs:+1:9: +1:10
+        let _13: usize;                  // in scope 1 at $DIR/loops.rs:+1:9: +1:10
         scope 2 {
-            debug i => _8;               // in scope 2 at $DIR/loops.rs:+1:9: +1:10
+            debug i => _13;              // in scope 2 at $DIR/loops.rs:+1:9: +1:10
         }
         scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { // at $DIR/loops.rs:8:14: 8:24
             debug self => _5;            // in scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+            scope 5 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                debug self => _5;        // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let mut _6: &usize;      // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let mut _7: &usize;      // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let mut _8: bool;        // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let _10: usize;          // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let mut _11: usize;      // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                scope 6 {
+                    debug old => _10;    // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                    scope 7 {
+                    }
+                }
+            }
         }
     }
     scope 3 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) { // at $DIR/loops.rs:8:14: 8:24
@@ -32,39 +45,74 @@ fn int_range(_1: usize, _2: usize) -> () {
     }
 
     bb1: {
-        StorageLive(_6);                 // scope 1 at $DIR/loops.rs:+1:14: +1:24
+        StorageLive(_9);                 // scope 1 at $DIR/loops.rs:+1:14: +1:24
         _5 = &mut _4;                    // scope 1 at $DIR/loops.rs:+1:14: +1:24
-        _6 = <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next(_5) -> bb2; // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_10);                // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_8);                 // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_6);                 // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _6 = &((*_5).0: usize);          // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_7);                 // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _7 = &((*_5).1: usize);          // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _8 = <usize as PartialOrd>::lt(move _6, move _7) -> bb2; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
                                          // mir::Constant
                                          // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
-                                         // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<usize>) -> Option<<std::ops::Range<usize> as iter::range::RangeIteratorImpl>::Item> {<std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next}, val: Value(<ZST>) }
+                                         // + literal: Const { ty: for<'a, 'b> fn(&'a usize, &'b usize) -> bool {<usize as PartialOrd>::lt}, val: Value(<ZST>) }
     }
 
     bb2: {
-        _7 = discriminant(_6);           // scope 1 at $DIR/loops.rs:+1:14: +1:24
-        switchInt(move _7) -> [0: bb3, 1: bb4, otherwise: bb6]; // scope 1 at $DIR/loops.rs:+1:14: +1:24
+        StorageDead(_7);                 // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageDead(_6);                 // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        switchInt(move _8) -> [0: bb3, otherwise: bb4]; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
     }
 
     bb3: {
-        StorageDead(_6);                 // scope 1 at $DIR/loops.rs:+3:5: +3:6
+        _9 = Option::<usize>::None;      // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        goto -> bb6;                     // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+    }
+
+    bb4: {
+        _10 = ((*_5).0: usize);          // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_11);                // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _11 = <usize as Step>::forward_unchecked(_10, const 1_usize) -> bb5; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
+                                         // + literal: Const { ty: unsafe fn(usize, usize) -> usize {<usize as Step>::forward_unchecked}, val: Value(<ZST>) }
+    }
+
+    bb5: {
+        ((*_5).0: usize) = move _11;     // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageDead(_11);                // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _9 = Option::<usize>::Some(_10); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        goto -> bb6;                     // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+    }
+
+    bb6: {
+        StorageDead(_8);                 // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageDead(_10);                // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _12 = discriminant(_9);          // scope 1 at $DIR/loops.rs:+1:14: +1:24
+        switchInt(move _12) -> [0: bb7, 1: bb8, otherwise: bb10]; // scope 1 at $DIR/loops.rs:+1:14: +1:24
+    }
+
+    bb7: {
+        StorageDead(_9);                 // scope 1 at $DIR/loops.rs:+3:5: +3:6
         StorageDead(_4);                 // scope 0 at $DIR/loops.rs:+3:5: +3:6
         return;                          // scope 0 at $DIR/loops.rs:+4:2: +4:2
     }
 
-    bb4: {
-        _8 = ((_6 as Some).0: usize);    // scope 1 at $DIR/loops.rs:+1:9: +1:10
-        _9 = opaque::<usize>(_8) -> bb5; // scope 2 at $DIR/loops.rs:+2:9: +2:18
+    bb8: {
+        _13 = ((_9 as Some).0: usize);   // scope 1 at $DIR/loops.rs:+1:9: +1:10
+        _14 = opaque::<usize>(_13) -> bb9; // scope 2 at $DIR/loops.rs:+2:9: +2:18
                                          // mir::Constant
                                          // + span: $DIR/loops.rs:9:9: 9:15
                                          // + literal: Const { ty: fn(usize) {opaque::<usize>}, val: Value(<ZST>) }
     }
 
-    bb5: {
-        StorageDead(_6);                 // scope 1 at $DIR/loops.rs:+3:5: +3:6
+    bb9: {
+        StorageDead(_9);                 // scope 1 at $DIR/loops.rs:+3:5: +3:6
         goto -> bb1;                     // scope 1 at $DIR/loops.rs:+1:5: +3:6
     }
 
-    bb6: {
+    bb10: {
         unreachable;                     // scope 1 at $DIR/loops.rs:+1:14: +1:24
     }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir
index 492cb022bed..91c8f299fdb 100644
--- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir
@@ -14,11 +14,11 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2
     let _12: &usize;                     // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46
     let mut _13: &&usize;                // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46
     let mut _18: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46
-    let mut _19: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56
-    let mut _20: &&usize;                // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51
-    let _21: &usize;                     // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56
-    let mut _22: &&usize;                // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56
-    let mut _27: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56
+    let mut _19: &&usize;                // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51
+    let _20: &usize;                     // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56
+    let mut _21: &&usize;                // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56
+    let mut _26: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56
+    let mut _27: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56
     let mut _28: &&usize;                // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:61
     let _29: &usize;                     // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66
     let mut _30: &&usize;                // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66
@@ -58,15 +58,15 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2
             }
         }
         scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:7:50: 7:56
-            debug self => _20;           // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
-            debug other => _22;          // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
+            debug self => _19;           // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
+            debug other => _21;          // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
+            let mut _22: &usize;         // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
             let mut _23: &usize;         // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
-            let mut _24: &usize;         // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
             scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL
-                debug self => _23;       // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
-                debug other => _24;      // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
+                debug self => _22;       // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
+                debug other => _23;      // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
+                let mut _24: usize;      // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
                 let mut _25: usize;      // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
-                let mut _26: usize;      // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
             }
         }
         scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:7:70: 7:76
@@ -96,7 +96,7 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2
         StorageLive(_10);                // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
         _9 = deref_copy (*_2);           // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
         _10 = &((*_9).3: usize);         // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
-        StorageLive(_19);                // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56
+        StorageLive(_27);                // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56
         StorageLive(_18);                // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46
         StorageLive(_11);                // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41
         _11 = &_4;                       // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41
@@ -120,41 +120,38 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2
     }
 
     bb1: {
-        _19 = const false;               // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56
+        StorageDead(_26);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        StorageDead(_18);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
         goto -> bb3;                     // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56
     }
 
     bb2: {
-        StorageLive(_27);                // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56
-        StorageLive(_20);                // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51
-        _20 = &_10;                      // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51
-        StorageLive(_22);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        StorageLive(_26);                // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56
+        StorageLive(_19);                // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51
+        _19 = &_10;                      // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51
         StorageLive(_21);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
-        _21 = _6;                        // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
-        _22 = &_21;                      // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
-        _23 = deref_copy (*_20);         // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
-        _24 = deref_copy (*_22);         // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
+        StorageLive(_20);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        _20 = _6;                        // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        _21 = &_20;                      // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        _22 = deref_copy (*_19);         // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
+        _23 = deref_copy (*_21);         // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL
+        StorageLive(_24);                // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
+        _24 = (*_22);                    // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
         StorageLive(_25);                // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
         _25 = (*_23);                    // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
-        StorageLive(_26);                // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
-        _26 = (*_24);                    // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
-        _27 = Le(move _25, move _26);    // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
-        StorageDead(_26);                // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
+        _26 = Le(move _24, move _25);    // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
         StorageDead(_25);                // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
-        StorageDead(_21);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
-        StorageDead(_22);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        StorageDead(_24);                // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL
         StorageDead(_20);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
-        _19 = move _27;                  // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56
-        goto -> bb3;                     // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56
-    }
-
-    bb3: {
-        StorageDead(_27);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        StorageDead(_21);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        StorageDead(_19);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
+        _27 = move _26;                  // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56
+        StorageDead(_26);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
         StorageDead(_18);                // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56
-        switchInt(move _19) -> [0: bb4, otherwise: bb8]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76
+        switchInt(move _27) -> [0: bb3, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76
     }
 
-    bb4: {
+    bb3: {
         StorageLive(_36);                // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
         StorageLive(_35);                // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66
         StorageLive(_28);                // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61
@@ -175,15 +172,15 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2
         StorageDead(_29);                // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66
         StorageDead(_30);                // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66
         StorageDead(_28);                // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66
-        switchInt(move _35) -> [0: bb5, otherwise: bb6]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
+        switchInt(move _35) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
     }
 
-    bb5: {
+    bb4: {
         _36 = const false;               // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
-        goto -> bb7;                     // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
+        goto -> bb6;                     // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
     }
 
-    bb6: {
+    bb5: {
         StorageLive(_44);                // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76
         StorageLive(_37);                // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71
         _37 = &_6;                       // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71
@@ -204,24 +201,24 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2
         StorageDead(_39);                // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76
         StorageDead(_37);                // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76
         _36 = move _44;                  // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
-        goto -> bb7;                     // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
+        goto -> bb6;                     // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76
     }
 
-    bb7: {
+    bb6: {
         StorageDead(_44);                // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76
         StorageDead(_35);                // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76
         _0 = move _36;                   // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76
-        goto -> bb9;                     // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76
+        goto -> bb8;                     // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76
     }
 
-    bb8: {
+    bb7: {
         _0 = const true;                 // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76
-        goto -> bb9;                     // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76
+        goto -> bb8;                     // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76
     }
 
-    bb9: {
+    bb8: {
         StorageDead(_36);                // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76
-        StorageDead(_19);                // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76
+        StorageDead(_27);                // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76
         StorageDead(_10);                // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76
         StorageDead(_8);                 // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76
         StorageDead(_6);                 // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76
diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir
index 8ab69bc7b27..9f5fe95a8b4 100644
--- a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir
@@ -11,8 +11,8 @@ fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:11:25: 11:41],
     let mut _9: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40
     let _10: usize;                      // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
     let mut _11: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48
-    let mut _12: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58
-    let mut _13: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58
+    let mut _12: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58
+    let mut _13: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58
     let mut _14: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68
     let mut _15: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78
     let mut _16: bool;                   // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78
@@ -32,64 +32,61 @@ fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:11:25: 11:41],
         _8 = ((*_7).2: usize);           // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
         _9 = deref_copy (*_2);           // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
         _10 = ((*_9).3: usize);          // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
-        StorageLive(_12);                // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
+        StorageLive(_13);                // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
         StorageLive(_11);                // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48
         _11 = Le(_4, _8);                // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48
         switchInt(move _11) -> [0: bb1, otherwise: bb2]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
     }
 
     bb1: {
-        _12 = const false;               // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
+        StorageDead(_12);                // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58
+        StorageDead(_11);                // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58
         goto -> bb3;                     // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
     }
 
     bb2: {
-        StorageLive(_13);                // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58
-        _13 = Le(_10, _6);               // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58
-        _12 = move _13;                  // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
-        goto -> bb3;                     // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
-    }
-
-    bb3: {
-        StorageDead(_13);                // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58
+        StorageLive(_12);                // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58
+        _12 = Le(_10, _6);               // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58
+        _13 = move _12;                  // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58
+        StorageDead(_12);                // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58
         StorageDead(_11);                // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58
-        switchInt(move _12) -> [0: bb4, otherwise: bb8]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
+        switchInt(move _13) -> [0: bb3, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
     }
 
-    bb4: {
+    bb3: {
         StorageLive(_15);                // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
         StorageLive(_14);                // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68
         _14 = Le(_8, _4);                // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68
-        switchInt(move _14) -> [0: bb5, otherwise: bb6]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
+        switchInt(move _14) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
     }
 
-    bb5: {
+    bb4: {
         _15 = const false;               // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
-        goto -> bb7;                     // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
+        goto -> bb6;                     // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
     }
 
-    bb6: {
+    bb5: {
         StorageLive(_16);                // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78
         _16 = Le(_6, _10);               // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78
         _15 = move _16;                  // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
-        goto -> bb7;                     // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
+        goto -> bb6;                     // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78
     }
 
-    bb7: {
+    bb6: {
         StorageDead(_16);                // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
         StorageDead(_14);                // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
         _0 = move _15;                   // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
-        goto -> bb9;                     // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
+        goto -> bb8;                     // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
     }
 
-    bb8: {
+    bb7: {
         _0 = const true;                 // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
-        goto -> bb9;                     // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
+        goto -> bb8;                     // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78
     }
 
-    bb9: {
+    bb8: {
         StorageDead(_15);                // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
-        StorageDead(_12);                // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
+        StorageDead(_13);                // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78
         return;                          // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78
     }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.mir
index 25a3421793d..4dd11c1e529 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.mir
@@ -42,21 +42,20 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
                         scope 13 (inlined NonNull::<T>::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL
                             debug ptr => _9; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
                             let mut _10: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
-                            let mut _24: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
                             scope 14 {
                                 scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
-                                    debug ptr => _24; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
+                                    debug ptr => _9; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
                                     scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
-                                        debug self => _24; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-                                        let mut _25: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
+                                        debug self => _9; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
+                                        let mut _24: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
                                         scope 17 {
                                             scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-                                                debug ptr => _25; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
+                                                debug ptr => _24; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
                                                 scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-                                                    debug self => _25; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
+                                                    debug self => _24; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
                                                     scope 20 {
                                                         scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
-                                                            debug self => _25; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
+                                                            debug self => _24; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
                                                         }
                                                     }
                                                 }
@@ -132,10 +131,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
         _9 = _4 as *mut T (PtrToPtr);    // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
         StorageLive(_10);                // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
         StorageLive(_24);                // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
-        StorageLive(_25);                // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
         _10 = _9 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
         _11 = NonNull::<T> { pointer: _10 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL
-        StorageDead(_25);                // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
         StorageDead(_24);                // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
         StorageDead(_10);                // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
         StorageDead(_9);                 // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL
diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir
index a81bd998d89..ca7a4a64f45 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir
@@ -8,25 +8,38 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     let mut _4: std::ops::Range<usize>;  // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28
     let mut _5: std::ops::Range<usize>;  // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28
     let mut _6: &mut std::ops::Range<usize>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28
-    let mut _7: std::option::Option<usize>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28
-    let mut _8: isize;                   // in scope 0 at $DIR/slice_iter.rs:+1:5: +4:6
-    let mut _10: usize;                  // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26
-    let mut _11: bool;                   // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26
-    let mut _13: &impl Fn(usize, &T);    // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:10
-    let mut _14: (usize, &T);            // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:16
-    let _15: ();                         // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28
+    let mut _10: std::option::Option<usize>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28
+    let mut _13: isize;                  // in scope 0 at $DIR/slice_iter.rs:+1:5: +4:6
+    let mut _15: usize;                  // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26
+    let mut _16: bool;                   // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26
+    let mut _18: &impl Fn(usize, &T);    // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:10
+    let mut _19: (usize, &T);            // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:16
+    let _20: ();                         // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28
     scope 1 {
         debug iter => _5;                // in scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
-        let _9: usize;                   // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10
+        let _14: usize;                  // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10
         scope 2 {
-            debug i => _9;               // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10
-            let _12: &T;                 // in scope 2 at $DIR/slice_iter.rs:+2:13: +2:14
+            debug i => _14;              // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10
+            let _17: &T;                 // in scope 2 at $DIR/slice_iter.rs:+2:13: +2:14
             scope 3 {
-                debug x => _12;          // in scope 3 at $DIR/slice_iter.rs:+2:13: +2:14
+                debug x => _17;          // in scope 3 at $DIR/slice_iter.rs:+2:13: +2:14
             }
         }
         scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { // at $DIR/slice_iter.rs:49:14: 49:28
             debug self => _6;            // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+            scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                debug self => _6;        // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let mut _7: &usize;      // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let mut _8: &usize;      // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let mut _9: bool;        // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let _11: usize;          // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                let mut _12: usize;      // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                scope 7 {
+                    debug old => _11;    // in scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                    scope 8 {
+                    }
+                }
+            }
         }
     }
     scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) { // at $DIR/slice_iter.rs:49:14: 49:28
@@ -44,64 +57,99 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb1: {
-        StorageLive(_7);                 // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
+        StorageLive(_10);                // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
         _6 = &mut _5;                    // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
-        _7 = <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next(_6) -> [return: bb2, unwind: bb9]; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_11);                // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_9);                 // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_7);                 // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _7 = &((*_6).0: usize);          // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_8);                 // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _8 = &((*_6).1: usize);          // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _9 = <usize as PartialOrd>::lt(move _7, move _8) -> [return: bb2, unwind: bb13]; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
                                          // mir::Constant
                                          // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
-                                         // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<usize>) -> Option<<std::ops::Range<usize> as iter::range::RangeIteratorImpl>::Item> {<std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next}, val: Value(<ZST>) }
+                                         // + literal: Const { ty: for<'a, 'b> fn(&'a usize, &'b usize) -> bool {<usize as PartialOrd>::lt}, val: Value(<ZST>) }
     }
 
     bb2: {
-        _8 = discriminant(_7);           // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
-        switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb8]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
+        StorageDead(_8);                 // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageDead(_7);                 // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        switchInt(move _9) -> [0: bb3, otherwise: bb4]; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
     }
 
     bb3: {
-        StorageDead(_7);                 // scope 1 at $DIR/slice_iter.rs:+4:5: +4:6
-        StorageDead(_5);                 // scope 0 at $DIR/slice_iter.rs:+4:5: +4:6
-        drop(_2) -> bb4;                 // scope 0 at $DIR/slice_iter.rs:+5:1: +5:2
+        _10 = Option::<usize>::None;     // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        goto -> bb6;                     // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
     }
 
     bb4: {
-        return;                          // scope 0 at $DIR/slice_iter.rs:+5:2: +5:2
+        _11 = ((*_6).0: usize);          // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageLive(_12);                // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _12 = <usize as Step>::forward_unchecked(_11, const 1_usize) -> [return: bb5, unwind: bb13]; // scope 8 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
+                                         // + literal: Const { ty: unsafe fn(usize, usize) -> usize {<usize as Step>::forward_unchecked}, val: Value(<ZST>) }
     }
 
     bb5: {
-        _9 = ((_7 as Some).0: usize);    // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10
-        _10 = Len((*_1));                // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26
-        _11 = Lt(_9, _10);               // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26
-        assert(move _11, "index out of bounds: the length is {} but the index is {}", move _10, _9) -> [success: bb6, unwind: bb9]; // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26
+        ((*_6).0: usize) = move _12;     // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageDead(_12);                // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _10 = Option::<usize>::Some(_11); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        goto -> bb6;                     // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
     }
 
     bb6: {
-        _12 = &(*_1)[_9];                // scope 2 at $DIR/slice_iter.rs:+2:17: +2:26
-        StorageLive(_13);                // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10
-        _13 = &_2;                       // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10
-        StorageLive(_14);                // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16
-        _14 = (_9, _12);                 // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16
-        _15 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _13, move _14) -> [return: bb7, unwind: bb9]; // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16
+        StorageDead(_9);                 // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        StorageDead(_11);                // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
+        _13 = discriminant(_10);         // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
+        switchInt(move _13) -> [0: bb7, 1: bb9, otherwise: bb12]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
+    }
+
+    bb7: {
+        StorageDead(_10);                // scope 1 at $DIR/slice_iter.rs:+4:5: +4:6
+        StorageDead(_5);                 // scope 0 at $DIR/slice_iter.rs:+4:5: +4:6
+        drop(_2) -> bb8;                 // scope 0 at $DIR/slice_iter.rs:+5:1: +5:2
+    }
+
+    bb8: {
+        return;                          // scope 0 at $DIR/slice_iter.rs:+5:2: +5:2
+    }
+
+    bb9: {
+        _14 = ((_10 as Some).0: usize);  // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10
+        _15 = Len((*_1));                // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26
+        _16 = Lt(_14, _15);              // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26
+        assert(move _16, "index out of bounds: the length is {} but the index is {}", move _15, _14) -> [success: bb10, unwind: bb13]; // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26
+    }
+
+    bb10: {
+        _17 = &(*_1)[_14];               // scope 2 at $DIR/slice_iter.rs:+2:17: +2:26
+        StorageLive(_18);                // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10
+        _18 = &_2;                       // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10
+        StorageLive(_19);                // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16
+        _19 = (_14, _17);                // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16
+        _20 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _18, move _19) -> [return: bb11, unwind: bb13]; // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16
                                          // mir::Constant
                                          // + span: $DIR/slice_iter.rs:51:9: 51:10
                                          // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(usize, &T), (usize, &T)) -> <impl Fn(usize, &T) as FnOnce<(usize, &T)>>::Output {<impl Fn(usize, &T) as Fn<(usize, &T)>>::call}, val: Value(<ZST>) }
     }
 
-    bb7: {
-        StorageDead(_14);                // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16
-        StorageDead(_13);                // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16
-        StorageDead(_7);                 // scope 1 at $DIR/slice_iter.rs:+4:5: +4:6
+    bb11: {
+        StorageDead(_19);                // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16
+        StorageDead(_18);                // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16
+        StorageDead(_10);                // scope 1 at $DIR/slice_iter.rs:+4:5: +4:6
         goto -> bb1;                     // scope 1 at $DIR/slice_iter.rs:+1:5: +4:6
     }
 
-    bb8: {
+    bb12: {
         unreachable;                     // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28
     }
 
-    bb9 (cleanup): {
-        drop(_2) -> [return: bb10, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+5:1: +5:2
+    bb13 (cleanup): {
+        drop(_2) -> [return: bb14, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+5:1: +5:2
     }
 
-    bb10 (cleanup): {
+    bb14 (cleanup): {
         resume;                          // scope 0 at $DIR/slice_iter.rs:+0:1: +5:2
     }
 }