about summary refs log tree commit diff
path: root/tests/mir-opt/pre-codegen
diff options
context:
space:
mode:
authordianqk <dianqk@dianqk.net>2025-06-08 15:30:09 +0800
committerdianqk <dianqk@dianqk.net>2025-10-02 14:55:50 +0800
commit571412f8190089c36758031fe09fc0ece59be6b7 (patch)
tree3c1370be293a5aa1e4d8419ce9807b3f4b3b6ba1 /tests/mir-opt/pre-codegen
parent42b384ec0dfcd528d99a4db0a337d9188a9eecaa (diff)
downloadrust-571412f8190089c36758031fe09fc0ece59be6b7.tar.gz
rust-571412f8190089c36758031fe09fc0ece59be6b7.zip
mir-opt: Eliminate dead ref statements
Diffstat (limited to 'tests/mir-opt/pre-codegen')
-rw-r--r--tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir40
-rw-r--r--tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir40
-rw-r--r--tests/mir-opt/pre-codegen/clone_as_copy.clone_as_copy.PreCodegen.after.mir2
-rw-r--r--tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir6
-rw-r--r--tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir38
-rw-r--r--tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir38
-rw-r--r--tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir38
-rw-r--r--tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir38
-rw-r--r--tests/mir-opt/pre-codegen/drop_boxed_slice.rs2
-rw-r--r--tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir44
-rw-r--r--tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir100
-rw-r--r--tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir84
-rw-r--r--tests/mir-opt/pre-codegen/loops.rs1
-rw-r--r--tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir340
-rw-r--r--tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir199
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir14
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir14
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir14
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir223
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir231
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir8
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir8
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir189
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir189
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir14
-rw-r--r--tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir14
-rw-r--r--tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir2
-rw-r--r--tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir2
-rw-r--r--tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir8
-rw-r--r--tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir8
30 files changed, 1579 insertions, 369 deletions
diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir
index 83478e60b5d..23dbc066dd5 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir
@@ -5,7 +5,9 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
     debug n => _2;
     let mut _0: u16;
     scope 1 (inlined <u16 as Step>::forward) {
-        let mut _8: u16;
+        let _8: std::option::Option<u16>;
+        let mut _10: u16;
+        let mut _11: &std::option::Option<u16>;
         scope 2 {
         }
         scope 3 (inlined <u16 as Step>::forward_checked) {
@@ -13,8 +15,9 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
                 scope 6 (inlined core::num::<impl u16>::checked_add) {
                     let mut _5: (u16, bool);
                     let mut _6: bool;
+                    let mut _7: u16;
                     scope 7 (inlined std::intrinsics::unlikely) {
-                        let _7: ();
+                        let _9: ();
                     }
                 }
             }
@@ -35,6 +38,8 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
 
     bb0: {
         StorageLive(_4);
+        StorageLive(_11);
+        StorageLive(_8);
         StorageLive(_3);
         _3 = Gt(copy _2, const 65535_usize);
         switchInt(move _3) -> [0: bb1, otherwise: bb5];
@@ -53,34 +58,55 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
     bb2: {
         StorageDead(_5);
         StorageDead(_6);
+        StorageLive(_7);
+        _7 = AddUnchecked(copy _1, copy _4);
+        _8 = Option::<u16>::Some(move _7);
+        StorageDead(_7);
+        // DBG: _11 = &_8;
+        StorageDead(_8);
+        StorageDead(_11);
         goto -> bb7;
     }
 
     bb3: {
-        _7 = std::intrinsics::cold_path() -> [return: bb4, unwind unreachable];
+        _9 = std::intrinsics::cold_path() -> [return: bb4, unwind unreachable];
     }
 
     bb4: {
         StorageDead(_5);
         StorageDead(_6);
+        _8 = const Option::<u16>::None;
+        // DBG: _11 = &_8;
         goto -> bb6;
     }
 
     bb5: {
         StorageDead(_3);
+        _8 = const Option::<u16>::None;
+        // DBG: _11 = &_8;
         goto -> bb6;
     }
 
     bb6: {
+        StorageDead(_8);
+        StorageDead(_11);
         assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::<impl u16>::MAX, const 1_u16) -> [success: bb7, unwind unreachable];
     }
 
     bb7: {
-        StorageLive(_8);
-        _8 = copy _2 as u16 (IntToInt);
-        _0 = Add(copy _1, copy _8);
-        StorageDead(_8);
+        StorageLive(_10);
+        _10 = copy _2 as u16 (IntToInt);
+        _0 = Add(copy _1, copy _10);
+        StorageDead(_10);
         StorageDead(_4);
         return;
     }
 }
+
+ALLOC0 (size: 4, align: 2) {
+    00 00 __ __                                     │ ..░░
+}
+
+ALLOC1 (size: 4, align: 2) {
+    00 00 __ __                                     │ ..░░
+}
diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir
index ac7a6e04451..ac15f070597 100644
--- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir
@@ -5,7 +5,9 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
     debug n => _2;
     let mut _0: u16;
     scope 1 (inlined <u16 as Step>::forward) {
-        let mut _8: u16;
+        let _8: std::option::Option<u16>;
+        let mut _10: u16;
+        let mut _11: &std::option::Option<u16>;
         scope 2 {
         }
         scope 3 (inlined <u16 as Step>::forward_checked) {
@@ -13,8 +15,9 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
                 scope 6 (inlined core::num::<impl u16>::checked_add) {
                     let mut _5: (u16, bool);
                     let mut _6: bool;
+                    let mut _7: u16;
                     scope 7 (inlined std::intrinsics::unlikely) {
-                        let _7: ();
+                        let _9: ();
                     }
                 }
             }
@@ -35,6 +38,8 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
 
     bb0: {
         StorageLive(_4);
+        StorageLive(_11);
+        StorageLive(_8);
         StorageLive(_3);
         _3 = Gt(copy _2, const 65535_usize);
         switchInt(move _3) -> [0: bb1, otherwise: bb5];
@@ -53,34 +58,55 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
     bb2: {
         StorageDead(_5);
         StorageDead(_6);
+        StorageLive(_7);
+        _7 = AddUnchecked(copy _1, copy _4);
+        _8 = Option::<u16>::Some(move _7);
+        StorageDead(_7);
+        // DBG: _11 = &_8;
+        StorageDead(_8);
+        StorageDead(_11);
         goto -> bb7;
     }
 
     bb3: {
-        _7 = std::intrinsics::cold_path() -> [return: bb4, unwind unreachable];
+        _9 = std::intrinsics::cold_path() -> [return: bb4, unwind unreachable];
     }
 
     bb4: {
         StorageDead(_5);
         StorageDead(_6);
+        _8 = const Option::<u16>::None;
+        // DBG: _11 = &_8;
         goto -> bb6;
     }
 
     bb5: {
         StorageDead(_3);
+        _8 = const Option::<u16>::None;
+        // DBG: _11 = &_8;
         goto -> bb6;
     }
 
     bb6: {
+        StorageDead(_8);
+        StorageDead(_11);
         assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::<impl u16>::MAX, const 1_u16) -> [success: bb7, unwind continue];
     }
 
     bb7: {
-        StorageLive(_8);
-        _8 = copy _2 as u16 (IntToInt);
-        _0 = Add(copy _1, copy _8);
-        StorageDead(_8);
+        StorageLive(_10);
+        _10 = copy _2 as u16 (IntToInt);
+        _0 = Add(copy _1, copy _10);
+        StorageDead(_10);
         StorageDead(_4);
         return;
     }
 }
+
+ALLOC0 (size: 4, align: 2) {
+    00 00 __ __                                     │ ..░░
+}
+
+ALLOC1 (size: 4, align: 2) {
+    00 00 __ __                                     │ ..░░
+}
diff --git a/tests/mir-opt/pre-codegen/clone_as_copy.clone_as_copy.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/clone_as_copy.clone_as_copy.PreCodegen.after.mir
index 34747e5a928..66239a0ef66 100644
--- a/tests/mir-opt/pre-codegen/clone_as_copy.clone_as_copy.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/clone_as_copy.clone_as_copy.PreCodegen.after.mir
@@ -13,7 +13,7 @@ fn clone_as_copy(_1: &NestCopy) -> NestCopy {
 
     bb0: {
         StorageLive(_2);
-        _2 = &((*_1).1: AllCopy);
+        // DBG: _2 = &((*_1).1: AllCopy);
         _0 = copy (*_1);
         StorageDead(_2);
         return;
diff --git a/tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir
index e67f362ee04..aa03cec070a 100644
--- a/tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir
@@ -35,15 +35,15 @@ fn enum_clone_as_copy(_1: &Enum1) -> Enum1 {
     }
 
     bb1: {
-        _3 = &(((*_1) as A).0: AllCopy);
+        // DBG: _3 = &(((*_1) as A).0: AllCopy);
         _0 = copy (*_1);
         goto -> bb3;
     }
 
     bb2: {
-        _4 = &(((*_1) as B).0: NestCopy);
+        // DBG: _4 = &(((*_1) as B).0: NestCopy);
         StorageLive(_5);
-        _5 = &((((*_1) as B).0: NestCopy).1: AllCopy);
+        // DBG: _5 = &((((*_1) as B).0: NestCopy).1: AllCopy);
         StorageDead(_5);
         _0 = copy (*_1);
         goto -> bb3;
diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir
index ba6ce0ee528..0dd2125dbe0 100644
--- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir
@@ -8,9 +8,10 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
             let _2: std::ptr::NonNull<[T]>;
             let mut _3: *mut [T];
             let mut _4: *const [T];
-            let _11: ();
+            let _12: ();
+            let mut _13: &std::alloc::Layout;
             scope 3 {
-                let _8: std::ptr::alignment::AlignmentEnum;
+                let _8: std::alloc::Layout;
                 scope 4 {
                     scope 12 (inlined Layout::size) {
                     }
@@ -26,15 +27,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
                     }
                     scope 18 (inlined <std::alloc::Global as Allocator>::deallocate) {
                         let mut _9: *mut u8;
+                        let mut _14: &std::alloc::Layout;
                         scope 19 (inlined Layout::size) {
                         }
                         scope 20 (inlined NonNull::<u8>::as_ptr) {
                         }
                         scope 21 (inlined std::alloc::dealloc) {
-                            let mut _10: usize;
+                            let mut _11: usize;
+                            let mut _15: &std::alloc::Layout;
+                            let mut _16: &std::alloc::Layout;
                             scope 22 (inlined Layout::size) {
                             }
                             scope 23 (inlined Layout::align) {
+                                let mut _10: std::ptr::alignment::AlignmentEnum;
                                 scope 24 (inlined std::ptr::Alignment::as_usize) {
                                 }
                             }
@@ -63,6 +68,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
     }
 
     bb0: {
+        StorageLive(_8);
         StorageLive(_2);
         _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>);
         StorageLive(_4);
@@ -74,31 +80,45 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
 
     bb1: {
         _6 = AlignOf(T);
-        StorageLive(_7);
         _7 = copy _6 as std::ptr::Alignment (Transmute);
-        _8 = move (_7.0: std::ptr::alignment::AlignmentEnum);
-        StorageDead(_7);
+        _8 = Layout { size: copy _5, align: copy _7 };
         StorageDead(_6);
         StorageDead(_4);
+        StorageLive(_13);
+        // DBG: _13 = &_8;
+        StorageDead(_13);
         switchInt(copy _5) -> [0: bb4, otherwise: bb2];
     }
 
     bb2: {
+        StorageLive(_14);
+        // DBG: _14 = &_8;
+        StorageDead(_14);
         StorageLive(_9);
         _9 = copy _3 as *mut u8 (PtrToPtr);
+        StorageLive(_15);
+        // DBG: _15 = &_8;
+        StorageDead(_15);
+        StorageLive(_11);
+        StorageLive(_16);
+        // DBG: _16 = &_8;
         StorageLive(_10);
-        _10 = discriminant(_8);
-        _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
+        _10 = copy (_7.0: std::ptr::alignment::AlignmentEnum);
+        _11 = discriminant(_10);
+        StorageDead(_10);
+        StorageDead(_16);
+        _12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        StorageDead(_10);
+        StorageDead(_11);
         StorageDead(_9);
         goto -> bb4;
     }
 
     bb4: {
         StorageDead(_2);
+        StorageDead(_8);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir
index ba6ce0ee528..0dd2125dbe0 100644
--- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir
@@ -8,9 +8,10 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
             let _2: std::ptr::NonNull<[T]>;
             let mut _3: *mut [T];
             let mut _4: *const [T];
-            let _11: ();
+            let _12: ();
+            let mut _13: &std::alloc::Layout;
             scope 3 {
-                let _8: std::ptr::alignment::AlignmentEnum;
+                let _8: std::alloc::Layout;
                 scope 4 {
                     scope 12 (inlined Layout::size) {
                     }
@@ -26,15 +27,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
                     }
                     scope 18 (inlined <std::alloc::Global as Allocator>::deallocate) {
                         let mut _9: *mut u8;
+                        let mut _14: &std::alloc::Layout;
                         scope 19 (inlined Layout::size) {
                         }
                         scope 20 (inlined NonNull::<u8>::as_ptr) {
                         }
                         scope 21 (inlined std::alloc::dealloc) {
-                            let mut _10: usize;
+                            let mut _11: usize;
+                            let mut _15: &std::alloc::Layout;
+                            let mut _16: &std::alloc::Layout;
                             scope 22 (inlined Layout::size) {
                             }
                             scope 23 (inlined Layout::align) {
+                                let mut _10: std::ptr::alignment::AlignmentEnum;
                                 scope 24 (inlined std::ptr::Alignment::as_usize) {
                                 }
                             }
@@ -63,6 +68,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
     }
 
     bb0: {
+        StorageLive(_8);
         StorageLive(_2);
         _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>);
         StorageLive(_4);
@@ -74,31 +80,45 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
 
     bb1: {
         _6 = AlignOf(T);
-        StorageLive(_7);
         _7 = copy _6 as std::ptr::Alignment (Transmute);
-        _8 = move (_7.0: std::ptr::alignment::AlignmentEnum);
-        StorageDead(_7);
+        _8 = Layout { size: copy _5, align: copy _7 };
         StorageDead(_6);
         StorageDead(_4);
+        StorageLive(_13);
+        // DBG: _13 = &_8;
+        StorageDead(_13);
         switchInt(copy _5) -> [0: bb4, otherwise: bb2];
     }
 
     bb2: {
+        StorageLive(_14);
+        // DBG: _14 = &_8;
+        StorageDead(_14);
         StorageLive(_9);
         _9 = copy _3 as *mut u8 (PtrToPtr);
+        StorageLive(_15);
+        // DBG: _15 = &_8;
+        StorageDead(_15);
+        StorageLive(_11);
+        StorageLive(_16);
+        // DBG: _16 = &_8;
         StorageLive(_10);
-        _10 = discriminant(_8);
-        _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
+        _10 = copy (_7.0: std::ptr::alignment::AlignmentEnum);
+        _11 = discriminant(_10);
+        StorageDead(_10);
+        StorageDead(_16);
+        _12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        StorageDead(_10);
+        StorageDead(_11);
         StorageDead(_9);
         goto -> bb4;
     }
 
     bb4: {
         StorageDead(_2);
+        StorageDead(_8);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir
index ba6ce0ee528..0dd2125dbe0 100644
--- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir
@@ -8,9 +8,10 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
             let _2: std::ptr::NonNull<[T]>;
             let mut _3: *mut [T];
             let mut _4: *const [T];
-            let _11: ();
+            let _12: ();
+            let mut _13: &std::alloc::Layout;
             scope 3 {
-                let _8: std::ptr::alignment::AlignmentEnum;
+                let _8: std::alloc::Layout;
                 scope 4 {
                     scope 12 (inlined Layout::size) {
                     }
@@ -26,15 +27,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
                     }
                     scope 18 (inlined <std::alloc::Global as Allocator>::deallocate) {
                         let mut _9: *mut u8;
+                        let mut _14: &std::alloc::Layout;
                         scope 19 (inlined Layout::size) {
                         }
                         scope 20 (inlined NonNull::<u8>::as_ptr) {
                         }
                         scope 21 (inlined std::alloc::dealloc) {
-                            let mut _10: usize;
+                            let mut _11: usize;
+                            let mut _15: &std::alloc::Layout;
+                            let mut _16: &std::alloc::Layout;
                             scope 22 (inlined Layout::size) {
                             }
                             scope 23 (inlined Layout::align) {
+                                let mut _10: std::ptr::alignment::AlignmentEnum;
                                 scope 24 (inlined std::ptr::Alignment::as_usize) {
                                 }
                             }
@@ -63,6 +68,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
     }
 
     bb0: {
+        StorageLive(_8);
         StorageLive(_2);
         _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>);
         StorageLive(_4);
@@ -74,31 +80,45 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
 
     bb1: {
         _6 = AlignOf(T);
-        StorageLive(_7);
         _7 = copy _6 as std::ptr::Alignment (Transmute);
-        _8 = move (_7.0: std::ptr::alignment::AlignmentEnum);
-        StorageDead(_7);
+        _8 = Layout { size: copy _5, align: copy _7 };
         StorageDead(_6);
         StorageDead(_4);
+        StorageLive(_13);
+        // DBG: _13 = &_8;
+        StorageDead(_13);
         switchInt(copy _5) -> [0: bb4, otherwise: bb2];
     }
 
     bb2: {
+        StorageLive(_14);
+        // DBG: _14 = &_8;
+        StorageDead(_14);
         StorageLive(_9);
         _9 = copy _3 as *mut u8 (PtrToPtr);
+        StorageLive(_15);
+        // DBG: _15 = &_8;
+        StorageDead(_15);
+        StorageLive(_11);
+        StorageLive(_16);
+        // DBG: _16 = &_8;
         StorageLive(_10);
-        _10 = discriminant(_8);
-        _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
+        _10 = copy (_7.0: std::ptr::alignment::AlignmentEnum);
+        _11 = discriminant(_10);
+        StorageDead(_10);
+        StorageDead(_16);
+        _12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        StorageDead(_10);
+        StorageDead(_11);
         StorageDead(_9);
         goto -> bb4;
     }
 
     bb4: {
         StorageDead(_2);
+        StorageDead(_8);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir
index ba6ce0ee528..0dd2125dbe0 100644
--- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir
@@ -8,9 +8,10 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
             let _2: std::ptr::NonNull<[T]>;
             let mut _3: *mut [T];
             let mut _4: *const [T];
-            let _11: ();
+            let _12: ();
+            let mut _13: &std::alloc::Layout;
             scope 3 {
-                let _8: std::ptr::alignment::AlignmentEnum;
+                let _8: std::alloc::Layout;
                 scope 4 {
                     scope 12 (inlined Layout::size) {
                     }
@@ -26,15 +27,19 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
                     }
                     scope 18 (inlined <std::alloc::Global as Allocator>::deallocate) {
                         let mut _9: *mut u8;
+                        let mut _14: &std::alloc::Layout;
                         scope 19 (inlined Layout::size) {
                         }
                         scope 20 (inlined NonNull::<u8>::as_ptr) {
                         }
                         scope 21 (inlined std::alloc::dealloc) {
-                            let mut _10: usize;
+                            let mut _11: usize;
+                            let mut _15: &std::alloc::Layout;
+                            let mut _16: &std::alloc::Layout;
                             scope 22 (inlined Layout::size) {
                             }
                             scope 23 (inlined Layout::align) {
+                                let mut _10: std::ptr::alignment::AlignmentEnum;
                                 scope 24 (inlined std::ptr::Alignment::as_usize) {
                                 }
                             }
@@ -63,6 +68,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
     }
 
     bb0: {
+        StorageLive(_8);
         StorageLive(_2);
         _2 = copy (((*_1).0: std::ptr::Unique<[T]>).0: std::ptr::NonNull<[T]>);
         StorageLive(_4);
@@ -74,31 +80,45 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
 
     bb1: {
         _6 = AlignOf(T);
-        StorageLive(_7);
         _7 = copy _6 as std::ptr::Alignment (Transmute);
-        _8 = move (_7.0: std::ptr::alignment::AlignmentEnum);
-        StorageDead(_7);
+        _8 = Layout { size: copy _5, align: copy _7 };
         StorageDead(_6);
         StorageDead(_4);
+        StorageLive(_13);
+        // DBG: _13 = &_8;
+        StorageDead(_13);
         switchInt(copy _5) -> [0: bb4, otherwise: bb2];
     }
 
     bb2: {
+        StorageLive(_14);
+        // DBG: _14 = &_8;
+        StorageDead(_14);
         StorageLive(_9);
         _9 = copy _3 as *mut u8 (PtrToPtr);
+        StorageLive(_15);
+        // DBG: _15 = &_8;
+        StorageDead(_15);
+        StorageLive(_11);
+        StorageLive(_16);
+        // DBG: _16 = &_8;
         StorageLive(_10);
-        _10 = discriminant(_8);
-        _11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
+        _10 = copy (_7.0: std::ptr::alignment::AlignmentEnum);
+        _11 = discriminant(_10);
+        StorageDead(_10);
+        StorageDead(_16);
+        _12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        StorageDead(_10);
+        StorageDead(_11);
         StorageDead(_9);
         goto -> bb4;
     }
 
     bb4: {
         StorageDead(_2);
+        StorageDead(_8);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs
index 9ceba9444b8..c291366a694 100644
--- a/tests/mir-opt/pre-codegen/drop_boxed_slice.rs
+++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.rs
@@ -11,7 +11,7 @@ pub unsafe fn generic_in_place<T: Copy>(ptr: *mut Box<[T]>) {
     // CHECK: [[SIZE:_.+]] = std::intrinsics::size_of_val::<[T]>
     // CHECK: [[ALIGN:_.+]] = AlignOf(T);
     // CHECK: [[B:_.+]] = copy [[ALIGN]] as std::ptr::Alignment (Transmute);
-    // CHECK: [[C:_.+]] = move ([[B]].0: std::ptr::alignment::AlignmentEnum);
+    // CHECK: [[C:_.+]] = copy ([[B]].0: std::ptr::alignment::AlignmentEnum);
     // CHECK: [[D:_.+]] = discriminant([[C]]);
     // CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[D]]) ->
     std::ptr::drop_in_place(ptr)
diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir
index 75e8cb1d861..8f30ad30fcc 100644
--- a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir
@@ -6,20 +6,20 @@ fn filter_mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> Option<U>) -> ()
     let mut _0: ();
     let mut _3: std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
     let mut _4: std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
-    let mut _5: &mut std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
-    let mut _8: std::option::Option<U>;
-    let mut _9: isize;
-    let _11: ();
+    let mut _7: std::option::Option<U>;
+    let mut _8: isize;
+    let _10: ();
+    let mut _11: &mut std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>;
     scope 1 {
         debug iter => _4;
-        let _10: U;
+        let _9: U;
         scope 2 {
-            debug x => _10;
+            debug x => _9;
         }
         scope 4 (inlined <FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>> as Iterator>::next) {
-            debug self => _5;
-            let mut _6: &mut impl Iterator<Item = T>;
-            let mut _7: &mut impl Fn(T) -> Option<U>;
+            debug self => _11;
+            let mut _5: &mut impl Iterator<Item = T>;
+            let mut _6: &mut impl Fn(T) -> Option<U>;
         }
     }
     scope 3 (inlined <FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>> as IntoIterator>::into_iter) {
@@ -37,24 +37,24 @@ fn filter_mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> Option<U>) -> ()
     }
 
     bb2: {
-        StorageLive(_8);
-        _5 = &mut _4;
-        StorageLive(_6);
-        _6 = &mut (_4.0: impl Iterator<Item = T>);
         StorageLive(_7);
-        _7 = &mut (_4.1: impl Fn(T) -> Option<U>);
-        _8 = <impl Iterator<Item = T> as Iterator>::find_map::<U, &mut impl Fn(T) -> Option<U>>(move _6, move _7) -> [return: bb3, unwind: bb9];
+        // DBG: _11 = &_4;
+        StorageLive(_5);
+        _5 = &mut (_4.0: impl Iterator<Item = T>);
+        StorageLive(_6);
+        _6 = &mut (_4.1: impl Fn(T) -> Option<U>);
+        _7 = <impl Iterator<Item = T> as Iterator>::find_map::<U, &mut impl Fn(T) -> Option<U>>(move _5, move _6) -> [return: bb3, unwind: bb9];
     }
 
     bb3: {
-        StorageDead(_7);
         StorageDead(_6);
-        _9 = discriminant(_8);
-        switchInt(move _9) -> [0: bb4, 1: bb6, otherwise: bb8];
+        StorageDead(_5);
+        _8 = discriminant(_7);
+        switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb8];
     }
 
     bb4: {
-        StorageDead(_8);
+        StorageDead(_7);
         drop(_4) -> [return: bb5, unwind continue];
     }
 
@@ -64,12 +64,12 @@ fn filter_mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> Option<U>) -> ()
     }
 
     bb6: {
-        _10 = move ((_8 as Some).0: U);
-        _11 = opaque::<U>(move _10) -> [return: bb7, unwind: bb9];
+        _9 = move ((_7 as Some).0: U);
+        _10 = opaque::<U>(move _9) -> [return: bb7, unwind: bb9];
     }
 
     bb7: {
-        StorageDead(_8);
+        StorageDead(_7);
         goto -> bb2;
     }
 
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 154cbd3791c..b1af3141ee6 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
@@ -5,32 +5,31 @@ fn int_range(_1: usize, _2: usize) -> () {
     debug end => _2;
     let mut _0: ();
     let mut _3: std::ops::Range<usize>;
-    let mut _4: std::ops::Range<usize>;
-    let mut _5: &mut std::ops::Range<usize>;
-    let mut _13: std::option::Option<usize>;
-    let _15: ();
+    let mut _9: std::option::Option<usize>;
+    let _11: ();
+    let mut _12: &mut std::ops::Range<usize>;
     scope 1 {
-        debug iter => _4;
-        let _14: usize;
+        debug iter => _3;
+        let _10: usize;
         scope 2 {
-            debug i => _14;
+            debug i => _10;
         }
         scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
-            debug self => _5;
+            debug self => _12;
             scope 5 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
-                debug self => _5;
-                let mut _6: &usize;
-                let mut _7: &usize;
-                let mut _10: bool;
-                let _11: usize;
-                let mut _12: usize;
+                debug self => _12;
+                let mut _6: bool;
+                let _7: usize;
+                let mut _8: usize;
+                let mut _13: &usize;
+                let mut _14: &usize;
                 scope 6 {
-                    debug old => _11;
+                    debug old => _7;
                     scope 8 (inlined <usize as Step>::forward_unchecked) {
-                        debug start => _11;
+                        debug start => _7;
                         debug n => const 1_usize;
                         scope 9 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) {
-                            debug self => _11;
+                            debug self => _7;
                             debug rhs => const 1_usize;
                             scope 10 (inlined core::ub_checks::check_language_ub) {
                                 scope 11 (inlined core::ub_checks::check_language_ub::runtime) {
@@ -40,10 +39,10 @@ fn int_range(_1: usize, _2: usize) -> () {
                     }
                 }
                 scope 7 (inlined std::cmp::impls::<impl PartialOrd for usize>::lt) {
-                    debug self => _6;
-                    debug other => _7;
-                    let mut _8: usize;
-                    let mut _9: usize;
+                    debug self => _13;
+                    debug other => _14;
+                    let mut _4: usize;
+                    let mut _5: usize;
                 }
             }
         }
@@ -54,54 +53,51 @@ fn int_range(_1: usize, _2: usize) -> () {
 
     bb0: {
         _3 = std::ops::Range::<usize> { start: copy _1, end: copy _2 };
-        StorageLive(_4);
-        _4 = copy _3;
         goto -> bb1;
     }
 
     bb1: {
-        StorageLive(_13);
-        _5 = &mut _4;
-        StorageLive(_10);
-        StorageLive(_6);
-        _6 = &(_4.0: usize);
-        StorageLive(_7);
-        _7 = &(_4.1: usize);
-        StorageLive(_8);
-        _8 = copy (_4.0: usize);
         StorageLive(_9);
-        _9 = copy (_4.1: usize);
-        _10 = Lt(move _8, move _9);
-        StorageDead(_9);
-        StorageDead(_8);
-        switchInt(move _10) -> [0: bb2, otherwise: bb3];
+        // DBG: _12 = &_3;
+        StorageLive(_6);
+        StorageLive(_13);
+        // DBG: _13 = &(_3.0: usize);
+        StorageLive(_14);
+        // DBG: _14 = &(_3.1: usize);
+        StorageLive(_4);
+        _4 = copy (_3.0: usize);
+        StorageLive(_5);
+        _5 = copy (_3.1: usize);
+        _6 = Lt(move _4, move _5);
+        StorageDead(_5);
+        StorageDead(_4);
+        switchInt(move _6) -> [0: bb2, otherwise: bb3];
     }
 
     bb2: {
-        StorageDead(_7);
-        StorageDead(_6);
-        StorageDead(_10);
+        StorageDead(_14);
         StorageDead(_13);
-        StorageDead(_4);
+        StorageDead(_6);
+        StorageDead(_9);
         return;
     }
 
     bb3: {
-        StorageDead(_7);
+        StorageDead(_14);
+        StorageDead(_13);
+        _7 = copy (_3.0: usize);
+        StorageLive(_8);
+        _8 = AddUnchecked(copy _7, const 1_usize);
+        (_3.0: usize) = move _8;
+        StorageDead(_8);
+        _9 = Option::<usize>::Some(copy _7);
         StorageDead(_6);
-        _11 = copy (_4.0: usize);
-        StorageLive(_12);
-        _12 = AddUnchecked(copy _11, const 1_usize);
-        (_4.0: usize) = move _12;
-        StorageDead(_12);
-        _13 = Option::<usize>::Some(copy _11);
-        StorageDead(_10);
-        _14 = copy ((_13 as Some).0: usize);
-        _15 = opaque::<usize>(move _14) -> [return: bb4, unwind continue];
+        _10 = copy ((_9 as Some).0: usize);
+        _11 = opaque::<usize>(move _10) -> [return: bb4, unwind continue];
     }
 
     bb4: {
-        StorageDead(_13);
+        StorageDead(_9);
         goto -> bb1;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir
index d22ea54004c..406c96fc32f 100644
--- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir
@@ -6,32 +6,32 @@ fn mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> U) -> () {
     let mut _0: ();
     let mut _3: std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>;
     let mut _4: std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>;
-    let mut _5: &mut std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>;
-    let mut _13: std::option::Option<U>;
-    let _15: ();
+    let mut _12: std::option::Option<U>;
+    let _14: ();
+    let mut _15: &mut std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>;
     scope 1 {
         debug iter => _4;
-        let _14: U;
+        let _13: U;
         scope 2 {
-            debug x => _14;
+            debug x => _13;
         }
         scope 4 (inlined <Map<impl Iterator<Item = T>, impl Fn(T) -> U> as Iterator>::next) {
-            debug self => _5;
-            let mut _6: &mut impl Iterator<Item = T>;
-            let mut _7: std::option::Option<T>;
-            let mut _8: &mut impl Fn(T) -> U;
+            debug self => _15;
+            let mut _5: &mut impl Iterator<Item = T>;
+            let mut _6: std::option::Option<T>;
+            let mut _7: &mut impl Fn(T) -> U;
             scope 5 (inlined Option::<T>::map::<U, &mut impl Fn(T) -> U>) {
-                debug self => _7;
-                debug f => _8;
-                let mut _9: isize;
-                let _10: T;
-                let mut _11: (T,);
-                let mut _12: U;
+                debug self => _6;
+                debug f => _7;
+                let mut _8: isize;
+                let _9: T;
+                let mut _10: (T,);
+                let mut _11: U;
                 scope 6 {
-                    debug x => _10;
+                    debug x => _9;
                     scope 7 (inlined ops::function::impls::<impl FnOnce<(T,)> for &mut impl Fn(T) -> U>::call_once) {
-                        debug self => _8;
-                        debug args => _11;
+                        debug self => _7;
+                        debug args => _10;
                     }
                 }
             }
@@ -52,30 +52,30 @@ fn mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> U) -> () {
     }
 
     bb2: {
-        StorageLive(_13);
-        _5 = &mut _4;
-        StorageLive(_8);
+        StorageLive(_12);
+        // DBG: _15 = &_4;
         StorageLive(_7);
         StorageLive(_6);
-        _6 = &mut (_4.0: impl Iterator<Item = T>);
-        _7 = <impl Iterator<Item = T> as Iterator>::next(move _6) -> [return: bb3, unwind: bb10];
+        StorageLive(_5);
+        _5 = &mut (_4.0: impl Iterator<Item = T>);
+        _6 = <impl Iterator<Item = T> as Iterator>::next(move _5) -> [return: bb3, unwind: bb10];
     }
 
     bb3: {
-        StorageDead(_6);
-        _8 = &mut (_4.1: impl Fn(T) -> U);
+        StorageDead(_5);
+        _7 = &mut (_4.1: impl Fn(T) -> U);
+        StorageLive(_8);
         StorageLive(_9);
-        StorageLive(_10);
-        _9 = discriminant(_7);
-        switchInt(move _9) -> [0: bb4, 1: bb6, otherwise: bb9];
+        _8 = discriminant(_6);
+        switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb9];
     }
 
     bb4: {
-        StorageDead(_10);
         StorageDead(_9);
-        StorageDead(_7);
         StorageDead(_8);
-        StorageDead(_13);
+        StorageDead(_6);
+        StorageDead(_7);
+        StorageDead(_12);
         drop(_4) -> [return: bb5, unwind continue];
     }
 
@@ -85,27 +85,27 @@ fn mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> U) -> () {
     }
 
     bb6: {
-        _10 = move ((_7 as Some).0: T);
-        StorageLive(_12);
+        _9 = move ((_6 as Some).0: T);
         StorageLive(_11);
-        _11 = (copy _10,);
-        _12 = <impl Fn(T) -> U as FnMut<(T,)>>::call_mut(move _8, move _11) -> [return: bb7, unwind: bb10];
+        StorageLive(_10);
+        _10 = (copy _9,);
+        _11 = <impl Fn(T) -> U as FnMut<(T,)>>::call_mut(move _7, move _10) -> [return: bb7, unwind: bb10];
     }
 
     bb7: {
-        StorageDead(_11);
-        _13 = Option::<U>::Some(move _12);
-        StorageDead(_12);
         StorageDead(_10);
+        _12 = Option::<U>::Some(move _11);
+        StorageDead(_11);
         StorageDead(_9);
-        StorageDead(_7);
         StorageDead(_8);
-        _14 = move ((_13 as Some).0: U);
-        _15 = opaque::<U>(move _14) -> [return: bb8, unwind: bb10];
+        StorageDead(_6);
+        StorageDead(_7);
+        _13 = move ((_12 as Some).0: U);
+        _14 = opaque::<U>(move _13) -> [return: bb8, unwind: bb10];
     }
 
     bb8: {
-        StorageDead(_13);
+        StorageDead(_12);
         goto -> bb2;
     }
 
diff --git a/tests/mir-opt/pre-codegen/loops.rs b/tests/mir-opt/pre-codegen/loops.rs
index d0b8cc8db7a..952dd8cac60 100644
--- a/tests/mir-opt/pre-codegen/loops.rs
+++ b/tests/mir-opt/pre-codegen/loops.rs
@@ -1,5 +1,6 @@
 // skip-filecheck
 //@ compile-flags: -O -Zmir-opt-level=2 -g
+//@ ignore-std-debug-assertions (debug assertions result in different inlines)
 //@ needs-unwind
 
 #![crate_type = "lib"]
diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir
index e537dd6a28e..03cdc221c30 100644
--- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir
+++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir
@@ -3,72 +3,354 @@
 fn vec_move(_1: Vec<impl Sized>) -> () {
     debug v => _1;
     let mut _0: ();
-    let mut _2: std::vec::IntoIter<impl Sized>;
-    let mut _3: std::vec::IntoIter<impl Sized>;
-    let mut _4: &mut std::vec::IntoIter<impl Sized>;
-    let mut _5: std::option::Option<impl Sized>;
-    let mut _6: isize;
-    let _8: ();
+    let mut _22: std::vec::IntoIter<impl Sized>;
+    let mut _23: std::vec::IntoIter<impl Sized>;
+    let mut _24: &mut std::vec::IntoIter<impl Sized>;
+    let mut _25: std::option::Option<impl Sized>;
+    let mut _26: isize;
+    let _28: ();
     scope 1 {
-        debug iter => _3;
-        let _7: impl Sized;
+        debug iter => _23;
+        let _27: impl Sized;
         scope 2 {
-            debug x => _7;
+            debug x => _27;
+        }
+    }
+    scope 3 (inlined <Vec<impl Sized> as IntoIterator>::into_iter) {
+        debug self => _1;
+        let _2: std::mem::ManuallyDrop<std::vec::Vec<impl Sized>>;
+        let mut _3: *const std::alloc::Global;
+        let mut _8: usize;
+        let mut _10: *mut impl Sized;
+        let mut _11: *const impl Sized;
+        let mut _12: usize;
+        let _29: &std::vec::Vec<impl Sized>;
+        let mut _30: &std::mem::ManuallyDrop<std::vec::Vec<impl Sized>>;
+        let mut _31: &alloc::raw_vec::RawVec<impl Sized>;
+        let mut _32: &std::mem::ManuallyDrop<std::vec::Vec<impl Sized>>;
+        let _33: &std::vec::Vec<impl Sized>;
+        let mut _34: &std::mem::ManuallyDrop<std::vec::Vec<impl Sized>>;
+        let _35: &std::vec::Vec<impl Sized>;
+        let mut _36: &std::mem::ManuallyDrop<std::vec::Vec<impl Sized>>;
+        let mut _37: &alloc::raw_vec::RawVec<impl Sized>;
+        let mut _38: &std::mem::ManuallyDrop<std::vec::Vec<impl Sized>>;
+        scope 4 {
+            debug me => _2;
+            scope 5 {
+                debug alloc => const ManuallyDrop::<std::alloc::Global> {{ value: std::alloc::Global }};
+                let _6: std::ptr::NonNull<impl Sized>;
+                scope 6 {
+                    debug buf => _6;
+                    let _7: *mut impl Sized;
+                    scope 7 {
+                        debug begin => _7;
+                        scope 8 {
+                            debug end => _11;
+                            let _20: usize;
+                            scope 9 {
+                                debug cap => _20;
+                            }
+                            scope 39 (inlined <ManuallyDrop<Vec<impl Sized>> as Deref>::deref) {
+                                debug self => _38;
+                            }
+                            scope 40 (inlined alloc::raw_vec::RawVec::<impl Sized>::capacity) {
+                                debug self => _37;
+                                let mut _19: usize;
+                                let mut _42: &alloc::raw_vec::RawVecInner;
+                                scope 41 (inlined std::mem::size_of::<impl Sized>) {
+                                }
+                                scope 42 (inlined alloc::raw_vec::RawVecInner::capacity) {
+                                    debug self => _42;
+                                    debug elem_size => _19;
+                                    let mut _21: core::num::niche_types::UsizeNoHighBit;
+                                    scope 43 (inlined core::num::niche_types::UsizeNoHighBit::as_inner) {
+                                        debug self => _21;
+                                    }
+                                }
+                            }
+                        }
+                        scope 25 (inlined <ManuallyDrop<Vec<impl Sized>> as Deref>::deref) {
+                            debug self => _34;
+                        }
+                        scope 26 (inlined Vec::<impl Sized>::len) {
+                            debug self => _33;
+                            let mut _13: bool;
+                            scope 27 {
+                            }
+                        }
+                        scope 28 (inlined std::ptr::mut_ptr::<impl *mut impl Sized>::wrapping_byte_add) {
+                            debug self => _7;
+                            debug count => _12;
+                            let mut _14: *mut u8;
+                            let mut _18: *mut u8;
+                            scope 29 (inlined std::ptr::mut_ptr::<impl *mut impl Sized>::cast::<u8>) {
+                                debug self => _7;
+                            }
+                            scope 30 (inlined std::ptr::mut_ptr::<impl *mut u8>::wrapping_add) {
+                                debug self => _14;
+                                debug count => _12;
+                                let mut _15: isize;
+                                scope 31 (inlined std::ptr::mut_ptr::<impl *mut u8>::wrapping_offset) {
+                                    debug self => _14;
+                                    debug count => _15;
+                                    let mut _16: *const u8;
+                                    let mut _17: *const u8;
+                                }
+                            }
+                            scope 32 (inlined std::ptr::mut_ptr::<impl *mut u8>::with_metadata_of::<impl Sized>) {
+                                debug self => _18;
+                                debug meta => _5;
+                                scope 33 (inlined std::ptr::metadata::<impl Sized>) {
+                                    debug ptr => _5;
+                                }
+                                scope 34 (inlined std::ptr::from_raw_parts_mut::<impl Sized, ()>) {
+                                }
+                            }
+                        }
+                        scope 35 (inlined <ManuallyDrop<Vec<impl Sized>> as Deref>::deref) {
+                            debug self => _36;
+                        }
+                        scope 36 (inlined Vec::<impl Sized>::len) {
+                            debug self => _35;
+                            let mut _9: bool;
+                            scope 37 {
+                            }
+                        }
+                        scope 38 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut impl Sized>::add) {
+                            debug self => _7;
+                            debug count => _8;
+                        }
+                    }
+                    scope 24 (inlined NonNull::<impl Sized>::as_ptr) {
+                        debug self => _6;
+                    }
+                }
+                scope 17 (inlined <ManuallyDrop<Vec<impl Sized>> as Deref>::deref) {
+                    debug self => _32;
+                }
+                scope 18 (inlined alloc::raw_vec::RawVec::<impl Sized>::non_null) {
+                    debug self => _31;
+                    let mut _41: &alloc::raw_vec::RawVecInner;
+                    scope 19 (inlined alloc::raw_vec::RawVecInner::non_null::<impl Sized>) {
+                        let mut _4: std::ptr::NonNull<u8>;
+                        scope 20 (inlined Unique::<u8>::cast::<impl Sized>) {
+                            scope 21 (inlined NonNull::<u8>::cast::<impl Sized>) {
+                                let mut _5: *const impl Sized;
+                                scope 22 (inlined NonNull::<u8>::as_ptr) {
+                                }
+                            }
+                        }
+                        scope 23 (inlined Unique::<impl Sized>::as_non_null_ptr) {
+                        }
+                    }
+                }
+            }
+            scope 11 (inlined <ManuallyDrop<Vec<impl Sized>> as Deref>::deref) {
+                debug self => _30;
+            }
+            scope 12 (inlined Vec::<impl Sized>::allocator) {
+                debug self => _29;
+                let mut _39: &alloc::raw_vec::RawVec<impl Sized>;
+                scope 13 (inlined alloc::raw_vec::RawVec::<impl Sized>::allocator) {
+                    let mut _40: &alloc::raw_vec::RawVecInner;
+                    scope 14 (inlined alloc::raw_vec::RawVecInner::allocator) {
+                    }
+                }
+            }
+            scope 15 (inlined #[track_caller] std::ptr::read::<std::alloc::Global>) {
+                debug src => _3;
+            }
+            scope 16 (inlined ManuallyDrop::<std::alloc::Global>::new) {
+                debug value => const std::alloc::Global;
+            }
+        }
+        scope 10 (inlined ManuallyDrop::<Vec<impl Sized>>::new) {
+            debug value => _1;
         }
     }
 
     bb0: {
+        StorageLive(_22);
+        StorageLive(_29);
+        StorageLive(_6);
+        StorageLive(_7);
+        StorageLive(_33);
+        StorageLive(_11);
+        StorageLive(_35);
+        StorageLive(_20);
+        StorageLive(_5);
+        StorageLive(_4);
+        StorageLive(_17);
         StorageLive(_2);
-        _2 = <Vec<impl Sized> as IntoIterator>::into_iter(move _1) -> [return: bb1, unwind continue];
+        _2 = ManuallyDrop::<Vec<impl Sized>> { value: copy _1 };
+        StorageLive(_3);
+        StorageLive(_30);
+        // DBG: _30 = &_2;
+        // DBG: _29 = &(_2.0: std::vec::Vec<impl Sized>);
+        StorageDead(_30);
+        StorageLive(_39);
+        // DBG: _39 = &((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>);
+        StorageLive(_40);
+        // DBG: _40 = &(((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>).0: alloc::raw_vec::RawVecInner);
+        StorageDead(_40);
+        StorageDead(_39);
+        _3 = &raw const ((((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>).0: alloc::raw_vec::RawVecInner).2: std::alloc::Global);
+        StorageDead(_3);
+        StorageLive(_31);
+        StorageLive(_32);
+        // DBG: _32 = &_2;
+        StorageDead(_32);
+        // DBG: _31 = &((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>);
+        StorageLive(_41);
+        // DBG: _41 = &(((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>).0: alloc::raw_vec::RawVecInner);
+        _4 = copy (((((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
+        _5 = copy _4 as *const impl Sized (Transmute);
+        _6 = NonNull::<impl Sized> { pointer: copy _5 };
+        StorageDead(_41);
+        StorageDead(_31);
+        _7 = copy _4 as *mut impl Sized (Transmute);
+        switchInt(const <impl Sized as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageLive(_3);
-        _3 = move _2;
-        goto -> bb2;
+        StorageLive(_10);
+        StorageLive(_8);
+        StorageLive(_36);
+        // DBG: _36 = &_2;
+        // DBG: _35 = &(_2.0: std::vec::Vec<impl Sized>);
+        StorageDead(_36);
+        _8 = copy ((_2.0: std::vec::Vec<impl Sized>).1: usize);
+        StorageLive(_9);
+        _9 = Le(copy _8, const <impl Sized as std::mem::SizedTypeProperties>::MAX_SLICE_LEN);
+        assume(move _9);
+        StorageDead(_9);
+        _10 = Offset(copy _7, copy _8);
+        _11 = copy _10 as *const impl Sized (PtrToPtr);
+        StorageDead(_8);
+        StorageDead(_10);
+        goto -> bb4;
     }
 
     bb2: {
-        StorageLive(_5);
-        _4 = &mut _3;
-        _5 = <std::vec::IntoIter<impl Sized> as Iterator>::next(move _4) -> [return: bb3, unwind: bb9];
+        StorageLive(_12);
+        StorageLive(_34);
+        // DBG: _34 = &_2;
+        // DBG: _33 = &(_2.0: std::vec::Vec<impl Sized>);
+        StorageDead(_34);
+        _12 = copy ((_2.0: std::vec::Vec<impl Sized>).1: usize);
+        StorageLive(_13);
+        _13 = Le(copy _12, const <impl Sized as std::mem::SizedTypeProperties>::MAX_SLICE_LEN);
+        assume(move _13);
+        StorageDead(_13);
+        StorageLive(_18);
+        StorageLive(_14);
+        _14 = copy _4 as *mut u8 (Transmute);
+        StorageLive(_15);
+        _15 = copy _12 as isize (IntToInt);
+        StorageLive(_16);
+        _16 = copy _4 as *const u8 (Transmute);
+        _17 = arith_offset::<u8>(move _16, move _15) -> [return: bb3, unwind unreachable];
     }
 
     bb3: {
-        _6 = discriminant(_5);
-        switchInt(move _6) -> [0: bb4, 1: bb6, otherwise: bb8];
+        StorageDead(_16);
+        _18 = copy _17 as *mut u8 (PtrToPtr);
+        StorageDead(_15);
+        StorageDead(_14);
+        StorageDead(_18);
+        StorageDead(_12);
+        _11 = copy _17 as *const impl Sized (PtrToPtr);
+        goto -> bb4;
     }
 
     bb4: {
-        StorageDead(_5);
-        drop(_3) -> [return: bb5, unwind continue];
+        StorageLive(_37);
+        StorageLive(_38);
+        // DBG: _38 = &_2;
+        StorageDead(_38);
+        // DBG: _37 = &((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>);
+        StorageLive(_42);
+        // DBG: _42 = &(((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>).0: alloc::raw_vec::RawVecInner);
+        StorageLive(_19);
+        _19 = SizeOf(impl Sized);
+        switchInt(move _19) -> [0: bb5, otherwise: bb6];
     }
 
     bb5: {
-        StorageDead(_3);
-        StorageDead(_2);
-        return;
+        _20 = const usize::MAX;
+        goto -> bb7;
     }
 
     bb6: {
-        _7 = move ((_5 as Some).0: impl Sized);
-        _8 = opaque::<impl Sized>(move _7) -> [return: bb7, unwind: bb9];
+        StorageLive(_21);
+        _21 = copy ((((_2.0: std::vec::Vec<impl Sized>).0: alloc::raw_vec::RawVec<impl Sized>).0: alloc::raw_vec::RawVecInner).1: core::num::niche_types::UsizeNoHighBit);
+        _20 = copy _21 as usize (Transmute);
+        StorageDead(_21);
+        goto -> bb7;
     }
 
     bb7: {
+        StorageDead(_19);
+        StorageDead(_42);
+        StorageDead(_37);
+        _22 = std::vec::IntoIter::<impl Sized> { buf: copy _6, phantom: const ZeroSized: PhantomData<impl Sized>, cap: move _20, alloc: const ManuallyDrop::<std::alloc::Global> {{ value: std::alloc::Global }}, ptr: copy _6, end: copy _11 };
+        StorageDead(_2);
+        StorageDead(_17);
+        StorageDead(_4);
         StorageDead(_5);
-        goto -> bb2;
+        StorageDead(_20);
+        StorageDead(_35);
+        StorageDead(_11);
+        StorageDead(_33);
+        StorageDead(_7);
+        StorageDead(_6);
+        StorageDead(_29);
+        StorageLive(_23);
+        _23 = move _22;
+        goto -> bb8;
     }
 
     bb8: {
+        StorageLive(_25);
+        _24 = &mut _23;
+        _25 = <std::vec::IntoIter<impl Sized> as Iterator>::next(move _24) -> [return: bb9, unwind: bb15];
+    }
+
+    bb9: {
+        _26 = discriminant(_25);
+        switchInt(move _26) -> [0: bb10, 1: bb12, otherwise: bb14];
+    }
+
+    bb10: {
+        StorageDead(_25);
+        drop(_23) -> [return: bb11, unwind continue];
+    }
+
+    bb11: {
+        StorageDead(_23);
+        StorageDead(_22);
+        return;
+    }
+
+    bb12: {
+        _27 = move ((_25 as Some).0: impl Sized);
+        _28 = opaque::<impl Sized>(move _27) -> [return: bb13, unwind: bb15];
+    }
+
+    bb13: {
+        StorageDead(_25);
+        goto -> bb8;
+    }
+
+    bb14: {
         unreachable;
     }
 
-    bb9 (cleanup): {
-        drop(_3) -> [return: bb10, unwind terminate(cleanup)];
+    bb15 (cleanup): {
+        drop(_23) -> [return: bb16, unwind terminate(cleanup)];
     }
 
-    bb10 (cleanup): {
+    bb16 (cleanup): {
         resume;
     }
 }
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 cbdd194afd3..9d4bacef954 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
@@ -3,183 +3,164 @@
 fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2: &&(usize, usize, usize, usize)) -> bool {
     let mut _0: bool;
     let mut _3: &(usize, usize, usize, usize);
-    let _4: &usize;
-    let _5: &usize;
-    let _6: &usize;
-    let _7: &usize;
-    let mut _8: &&usize;
-    let _9: &usize;
-    let mut _10: &&usize;
-    let mut _13: bool;
-    let mut _14: &&usize;
+    let mut _6: bool;
+    let mut _9: bool;
+    let mut _10: bool;
+    let _13: &usize;
+    let _14: &usize;
     let _15: &usize;
-    let mut _16: &&usize;
-    let mut _19: bool;
+    let _16: &usize;
+    let mut _17: &&usize;
+    let mut _18: &&usize;
+    let mut _19: &&usize;
     let mut _20: &&usize;
-    let _21: &usize;
+    let mut _21: &&usize;
     let mut _22: &&usize;
-    let mut _23: bool;
+    let mut _23: &&usize;
     let mut _24: &&usize;
-    let _25: &usize;
-    let mut _26: &&usize;
     scope 1 {
-        debug a => _4;
-        debug b => _5;
-        debug c => _6;
-        debug d => _7;
+        debug a => _13;
+        debug b => _14;
+        debug c => _15;
+        debug d => _16;
         scope 2 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) {
-            debug self => _8;
-            debug other => _10;
+            debug self => _17;
+            debug other => _18;
             scope 3 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) {
-                debug self => _4;
-                debug other => _6;
-                let mut _11: usize;
-                let mut _12: usize;
+                debug self => _13;
+                debug other => _15;
+                let mut _4: usize;
+                let mut _5: usize;
             }
         }
         scope 4 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) {
-            debug self => _14;
-            debug other => _16;
+            debug self => _19;
+            debug other => _20;
             scope 5 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) {
-                debug self => _7;
-                debug other => _5;
-                let mut _17: usize;
-                let mut _18: usize;
+                debug self => _16;
+                debug other => _14;
+                let mut _7: usize;
+                let mut _8: usize;
             }
         }
         scope 6 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) {
-            debug self => _20;
+            debug self => _21;
             debug other => _22;
             scope 7 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) {
-                debug self => _6;
-                debug other => _4;
+                debug self => _15;
+                debug other => _13;
             }
         }
         scope 8 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) {
-            debug self => _24;
-            debug other => _26;
+            debug self => _23;
+            debug other => _24;
             scope 9 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) {
-                debug self => _5;
-                debug other => _7;
-                let mut _27: usize;
-                let mut _28: usize;
+                debug self => _14;
+                debug other => _16;
+                let mut _11: usize;
+                let mut _12: usize;
             }
         }
     }
 
     bb0: {
         _3 = copy (*_2);
-        _4 = &((*_3).0: usize);
-        _5 = &((*_3).1: usize);
-        _6 = &((*_3).2: usize);
-        _7 = &((*_3).3: usize);
-        StorageLive(_13);
-        StorageLive(_8);
-        _8 = &_4;
-        StorageLive(_10);
-        StorageLive(_9);
-        _9 = copy _6;
-        _10 = &_9;
-        _11 = copy ((*_3).0: usize);
-        _12 = copy ((*_3).2: usize);
-        _13 = Le(copy _11, copy _12);
-        switchInt(move _13) -> [0: bb1, otherwise: bb2];
+        // DBG: _13 = &((*_3).0: usize);
+        // DBG: _14 = &((*_3).1: usize);
+        // DBG: _15 = &((*_3).2: usize);
+        // DBG: _16 = &((*_3).3: usize);
+        StorageLive(_6);
+        StorageLive(_17);
+        // DBG: _17 = &_13;
+        StorageLive(_18);
+        // DBG: _18 = &_15;
+        _4 = copy ((*_3).0: usize);
+        _5 = copy ((*_3).2: usize);
+        _6 = Le(copy _4, copy _5);
+        switchInt(move _6) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
-        StorageDead(_9);
-        StorageDead(_10);
-        StorageDead(_8);
+        StorageDead(_18);
+        StorageDead(_17);
         goto -> bb4;
     }
 
     bb2: {
-        StorageDead(_9);
-        StorageDead(_10);
-        StorageDead(_8);
-        StorageLive(_19);
-        StorageLive(_14);
-        _14 = &_7;
-        StorageLive(_16);
-        StorageLive(_15);
-        _15 = copy _5;
-        _16 = &_15;
-        StorageLive(_17);
-        _17 = copy ((*_3).3: usize);
-        StorageLive(_18);
-        _18 = copy ((*_3).1: usize);
-        _19 = Le(move _17, move _18);
         StorageDead(_18);
         StorageDead(_17);
-        switchInt(move _19) -> [0: bb3, otherwise: bb8];
+        StorageLive(_9);
+        StorageLive(_19);
+        // DBG: _19 = &_16;
+        StorageLive(_20);
+        // DBG: _20 = &_14;
+        StorageLive(_7);
+        _7 = copy ((*_3).3: usize);
+        StorageLive(_8);
+        _8 = copy ((*_3).1: usize);
+        _9 = Le(move _7, move _8);
+        StorageDead(_8);
+        StorageDead(_7);
+        switchInt(move _9) -> [0: bb3, otherwise: bb8];
     }
 
     bb3: {
-        StorageDead(_15);
-        StorageDead(_16);
-        StorageDead(_14);
+        StorageDead(_20);
+        StorageDead(_19);
         goto -> bb4;
     }
 
     bb4: {
-        StorageLive(_23);
-        StorageLive(_20);
-        _20 = &_6;
-        StorageLive(_22);
+        StorageLive(_10);
         StorageLive(_21);
-        _21 = copy _4;
-        _22 = &_21;
-        _23 = Le(copy _12, copy _11);
-        switchInt(move _23) -> [0: bb5, otherwise: bb6];
+        // DBG: _21 = &_15;
+        StorageLive(_22);
+        // DBG: _22 = &_13;
+        _10 = Le(copy _5, copy _4);
+        switchInt(move _10) -> [0: bb5, otherwise: bb6];
     }
 
     bb5: {
-        StorageDead(_21);
         StorageDead(_22);
-        StorageDead(_20);
+        StorageDead(_21);
         _0 = const false;
         goto -> bb7;
     }
 
     bb6: {
-        StorageDead(_21);
         StorageDead(_22);
-        StorageDead(_20);
+        StorageDead(_21);
+        StorageLive(_23);
+        // DBG: _23 = &_14;
         StorageLive(_24);
-        _24 = &_5;
-        StorageLive(_26);
-        StorageLive(_25);
-        _25 = copy _7;
-        _26 = &_25;
-        StorageLive(_27);
-        _27 = copy ((*_3).1: usize);
-        StorageLive(_28);
-        _28 = copy ((*_3).3: usize);
-        _0 = Le(move _27, move _28);
-        StorageDead(_28);
-        StorageDead(_27);
-        StorageDead(_25);
-        StorageDead(_26);
+        // DBG: _24 = &_16;
+        StorageLive(_11);
+        _11 = copy ((*_3).1: usize);
+        StorageLive(_12);
+        _12 = copy ((*_3).3: usize);
+        _0 = Le(move _11, move _12);
+        StorageDead(_12);
+        StorageDead(_11);
         StorageDead(_24);
+        StorageDead(_23);
         goto -> bb7;
     }
 
     bb7: {
-        StorageDead(_23);
+        StorageDead(_10);
         goto -> bb9;
     }
 
     bb8: {
-        StorageDead(_15);
-        StorageDead(_16);
-        StorageDead(_14);
+        StorageDead(_20);
+        StorageDead(_19);
         _0 = const true;
         goto -> bb9;
     }
 
     bb9: {
-        StorageDead(_19);
-        StorageDead(_13);
+        StorageDead(_9);
+        StorageDead(_6);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir
index 104987b0fdd..1b2e7b7163c 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir
@@ -51,6 +51,9 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
                 let mut _16: bool;
                 let mut _20: usize;
                 let _22: &T;
+                let mut _34: &std::ptr::NonNull<T>;
+                let mut _35: &std::ptr::NonNull<T>;
+                let mut _36: &std::ptr::NonNull<T>;
                 scope 29 {
                     let _12: *const T;
                     scope 30 {
@@ -186,7 +189,11 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
 
     bb5: {
         StorageLive(_16);
+        StorageLive(_34);
+        // DBG: _34 = &_11;
+        StorageLive(_35);
         _13 = copy _12 as std::ptr::NonNull<T> (Transmute);
+        // DBG: _35 = &_13;
         StorageLive(_14);
         _14 = copy _11 as *mut T (Transmute);
         StorageLive(_15);
@@ -198,6 +205,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb6: {
+        StorageDead(_35);
+        StorageDead(_34);
         StorageDead(_16);
         StorageLive(_18);
         StorageLive(_17);
@@ -210,6 +219,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb7: {
+        StorageDead(_35);
+        StorageDead(_34);
         StorageDead(_16);
         StorageDead(_22);
         StorageDead(_13);
@@ -255,10 +266,13 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
     }
 
     bb13: {
+        StorageLive(_36);
+        // DBG: _36 = &_11;
         StorageLive(_21);
         _21 = copy _11 as *const T (Transmute);
         _22 = &(*_21);
         StorageDead(_21);
+        StorageDead(_36);
         _23 = Option::<&T>::Some(copy _22);
         StorageDead(_22);
         StorageDead(_13);
diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir
index 4d0e3548e7d..c18dd01a189 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir
@@ -23,6 +23,9 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
             let mut _15: bool;
             let mut _19: usize;
             let _21: &T;
+            let mut _27: &std::ptr::NonNull<T>;
+            let mut _28: &std::ptr::NonNull<T>;
+            let mut _29: &std::ptr::NonNull<T>;
             scope 17 {
                 let _11: *const T;
                 scope 18 {
@@ -148,7 +151,11 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
 
     bb5: {
         StorageLive(_15);
+        StorageLive(_27);
+        // DBG: _27 = &_10;
+        StorageLive(_28);
         _12 = copy _11 as std::ptr::NonNull<T> (Transmute);
+        // DBG: _28 = &_12;
         StorageLive(_13);
         _13 = copy _10 as *mut T (Transmute);
         StorageLive(_14);
@@ -160,6 +167,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb6: {
+        StorageDead(_28);
+        StorageDead(_27);
         StorageDead(_15);
         StorageLive(_17);
         StorageLive(_16);
@@ -172,6 +181,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb7: {
+        StorageDead(_28);
+        StorageDead(_27);
         StorageDead(_15);
         StorageDead(_21);
         StorageDead(_12);
@@ -213,10 +224,13 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb13: {
+        StorageLive(_29);
+        // DBG: _29 = &_10;
         StorageLive(_20);
         _20 = copy _10 as *const T (Transmute);
         _21 = &(*_20);
         StorageDead(_20);
+        StorageDead(_29);
         _22 = Option::<&T>::Some(copy _21);
         StorageDead(_21);
         StorageDead(_12);
diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir
index 2b5d8c27d71..6334c611430 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir
@@ -23,6 +23,9 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
             let mut _15: bool;
             let mut _19: usize;
             let _21: &T;
+            let mut _27: &std::ptr::NonNull<T>;
+            let mut _28: &std::ptr::NonNull<T>;
+            let mut _29: &std::ptr::NonNull<T>;
             scope 17 {
                 let _11: *const T;
                 scope 18 {
@@ -148,7 +151,11 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
 
     bb5: {
         StorageLive(_15);
+        StorageLive(_27);
+        // DBG: _27 = &_10;
+        StorageLive(_28);
         _12 = copy _11 as std::ptr::NonNull<T> (Transmute);
+        // DBG: _28 = &_12;
         StorageLive(_13);
         _13 = copy _10 as *mut T (Transmute);
         StorageLive(_14);
@@ -160,6 +167,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb6: {
+        StorageDead(_28);
+        StorageDead(_27);
         StorageDead(_15);
         StorageLive(_17);
         StorageLive(_16);
@@ -172,6 +181,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb7: {
+        StorageDead(_28);
+        StorageDead(_27);
         StorageDead(_15);
         StorageDead(_21);
         StorageDead(_12);
@@ -213,10 +224,13 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb13: {
+        StorageLive(_29);
+        // DBG: _29 = &_10;
         StorageLive(_20);
         _20 = copy _10 as *const T (Transmute);
         _21 = &(*_20);
         StorageDead(_20);
+        StorageDead(_29);
         _22 = Option::<&T>::Some(copy _21);
         StorageDead(_21);
         StorageDead(_12);
diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir
index 0adf268d766..24c6618d31c 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir
@@ -7,19 +7,90 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     let mut _10: std::slice::Iter<'_, T>;
     let mut _11: std::iter::Rev<std::slice::Iter<'_, T>>;
     let mut _12: std::iter::Rev<std::slice::Iter<'_, T>>;
-    let mut _14: std::option::Option<&T>;
-    let mut _15: isize;
-    let mut _17: &impl Fn(&T);
-    let mut _18: (&T,);
-    let _19: ();
+    let mut _33: std::option::Option<&T>;
+    let mut _35: &impl Fn(&T);
+    let mut _36: (&T,);
+    let _37: ();
     scope 1 {
         debug iter => _12;
-        let _16: &T;
+        let _34: &T;
         scope 2 {
-            debug x => _16;
+            debug x => _34;
         }
         scope 18 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
-            let mut _13: &mut std::slice::Iter<'_, T>;
+            scope 19 (inlined <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back) {
+                let mut _13: *const T;
+                let mut _18: bool;
+                let mut _19: *const T;
+                let _32: &T;
+                let mut _38: &std::ptr::NonNull<T>;
+                let mut _39: &std::ptr::NonNull<T>;
+                scope 20 {
+                    let _14: std::ptr::NonNull<T>;
+                    let _20: usize;
+                    scope 21 {
+                    }
+                    scope 22 {
+                        scope 25 (inlined <NonNull<T> as PartialEq>::eq) {
+                            let mut _15: std::ptr::NonNull<T>;
+                            let mut _16: *mut T;
+                            let mut _17: *mut T;
+                            scope 26 (inlined NonNull::<T>::as_ptr) {
+                            }
+                            scope 27 (inlined NonNull::<T>::as_ptr) {
+                            }
+                        }
+                    }
+                    scope 23 (inlined std::ptr::const_ptr::<impl *const T>::addr) {
+                        scope 24 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) {
+                        }
+                    }
+                }
+                scope 28 (inlined std::slice::Iter::<'_, T>::next_back_unchecked) {
+                    let _26: std::ptr::NonNull<T>;
+                    let mut _40: &std::ptr::NonNull<T>;
+                    scope 29 (inlined std::slice::Iter::<'_, T>::pre_dec_end) {
+                        let mut _21: *mut *const T;
+                        let mut _22: *mut std::ptr::NonNull<T>;
+                        let mut _23: std::ptr::NonNull<T>;
+                        let mut _27: *mut *const T;
+                        let mut _28: *mut usize;
+                        let mut _29: usize;
+                        let mut _30: usize;
+                        scope 30 {
+                            scope 31 {
+                            }
+                            scope 32 {
+                                scope 35 (inlined NonNull::<T>::sub) {
+                                    scope 36 (inlined #[track_caller] core::num::<impl isize>::unchecked_neg) {
+                                        scope 37 (inlined core::ub_checks::check_language_ub) {
+                                            scope 38 (inlined core::ub_checks::check_language_ub::runtime) {
+                                            }
+                                        }
+                                    }
+                                    scope 39 (inlined NonNull::<T>::offset) {
+                                        let mut _24: *const T;
+                                        let mut _25: *const T;
+                                        scope 40 (inlined NonNull::<T>::as_ptr) {
+                                        }
+                                    }
+                                }
+                            }
+                            scope 33 (inlined std::ptr::mut_ptr::<impl *mut *const T>::cast::<usize>) {
+                            }
+                            scope 34 (inlined std::ptr::mut_ptr::<impl *mut *const T>::cast::<NonNull<T>>) {
+                            }
+                        }
+                    }
+                    scope 41 (inlined NonNull::<T>::as_ref::<'_>) {
+                        let _31: *const T;
+                        scope 42 (inlined NonNull::<T>::as_ptr) {
+                        }
+                        scope 43 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) {
+                        }
+                    }
+                }
+            }
         }
     }
     scope 3 (inlined core::slice::<impl [T]>::iter) {
@@ -105,45 +176,145 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb4: {
+        StorageLive(_33);
+        StorageLive(_20);
+        StorageLive(_19);
         StorageLive(_14);
-        StorageLive(_13);
-        _13 = &mut (_12.0: std::slice::Iter<'_, T>);
-        _14 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _13) -> [return: bb5, unwind unreachable];
+        StorageLive(_32);
+        StorageLive(_18);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb6];
     }
 
     bb5: {
+        StorageLive(_13);
+        _13 = copy ((_12.0: std::slice::Iter<'_, T>).1: *const T);
+        _14 = copy _13 as std::ptr::NonNull<T> (Transmute);
         StorageDead(_13);
-        _15 = discriminant(_14);
-        switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
+        StorageLive(_38);
+        // DBG: _38 = &((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>);
+        StorageLive(_39);
+        // DBG: _39 = &_14;
+        StorageLive(_16);
+        StorageLive(_15);
+        _15 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>);
+        _16 = copy _15 as *mut T (Transmute);
+        StorageDead(_15);
+        StorageLive(_17);
+        _17 = copy _14 as *mut T (Transmute);
+        _18 = Eq(copy _16, copy _17);
+        StorageDead(_17);
+        StorageDead(_16);
+        StorageDead(_39);
+        StorageDead(_38);
+        goto -> bb7;
     }
 
     bb6: {
-        StorageDead(_14);
-        StorageDead(_12);
-        drop(_2) -> [return: bb7, unwind unreachable];
+        _19 = copy ((_12.0: std::slice::Iter<'_, T>).1: *const T);
+        _20 = copy _19 as usize (Transmute);
+        _18 = Eq(copy _20, const 0_usize);
+        goto -> bb7;
     }
 
     bb7: {
-        return;
+        switchInt(move _18) -> [0: bb8, otherwise: bb15];
     }
 
     bb8: {
-        _16 = copy ((_14 as Some).0: &T);
-        StorageLive(_17);
-        _17 = &_2;
-        StorageLive(_18);
-        _18 = (copy _16,);
-        _19 = <impl Fn(&T) as Fn<(&T,)>>::call(move _17, move _18) -> [return: bb9, unwind unreachable];
+        StorageLive(_26);
+        StorageLive(_40);
+        StorageLive(_28);
+        StorageLive(_22);
+        StorageLive(_23);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb9, otherwise: bb12];
     }
 
     bb9: {
+        StorageLive(_21);
+        _21 = &raw mut ((_12.0: std::slice::Iter<'_, T>).1: *const T);
+        _22 = copy _21 as *mut std::ptr::NonNull<T> (PtrToPtr);
+        StorageDead(_21);
+        _23 = copy (*_22);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb10, otherwise: bb11];
+    }
+
+    bb10: {
+        StorageLive(_25);
+        StorageLive(_24);
+        _24 = copy _23 as *const T (Transmute);
+        _25 = Offset(copy _24, const -1_isize);
+        StorageDead(_24);
+        _23 = NonNull::<T> { pointer: copy _25 };
+        StorageDead(_25);
+        goto -> bb11;
+    }
+
+    bb11: {
+        (*_22) = move _23;
+        _26 = copy (*_22);
+        goto -> bb13;
+    }
+
+    bb12: {
+        StorageLive(_27);
+        _27 = &raw mut ((_12.0: std::slice::Iter<'_, T>).1: *const T);
+        _28 = copy _27 as *mut usize (PtrToPtr);
+        StorageDead(_27);
+        StorageLive(_30);
+        StorageLive(_29);
+        _29 = copy (*_28);
+        _30 = SubUnchecked(move _29, const 1_usize);
+        StorageDead(_29);
+        (*_28) = move _30;
+        StorageDead(_30);
+        _26 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>);
+        goto -> bb13;
+    }
+
+    bb13: {
+        StorageDead(_23);
+        StorageDead(_22);
+        StorageDead(_28);
+        // DBG: _40 = &_26;
+        StorageLive(_31);
+        _31 = copy _26 as *const T (Transmute);
+        _32 = &(*_31);
+        StorageDead(_31);
+        StorageDead(_40);
+        StorageDead(_26);
+        _33 = Option::<&T>::Some(copy _32);
         StorageDead(_18);
-        StorageDead(_17);
+        StorageDead(_32);
         StorageDead(_14);
+        StorageDead(_19);
+        StorageDead(_20);
+        _34 = copy ((_33 as Some).0: &T);
+        StorageLive(_35);
+        _35 = &_2;
+        StorageLive(_36);
+        _36 = (copy _34,);
+        _37 = <impl Fn(&T) as Fn<(&T,)>>::call(move _35, move _36) -> [return: bb14, unwind unreachable];
+    }
+
+    bb14: {
+        StorageDead(_36);
+        StorageDead(_35);
+        StorageDead(_33);
         goto -> bb4;
     }
 
-    bb10: {
-        unreachable;
+    bb15: {
+        StorageDead(_18);
+        StorageDead(_32);
+        StorageDead(_14);
+        StorageDead(_19);
+        StorageDead(_20);
+        StorageDead(_33);
+        StorageDead(_12);
+        drop(_2) -> [return: bb16, unwind unreachable];
+    }
+
+    bb16: {
+        return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir
index cb0d640d445..e5c7bcca44b 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir
@@ -7,19 +7,90 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     let mut _10: std::slice::Iter<'_, T>;
     let mut _11: std::iter::Rev<std::slice::Iter<'_, T>>;
     let mut _12: std::iter::Rev<std::slice::Iter<'_, T>>;
-    let mut _14: std::option::Option<&T>;
-    let mut _15: isize;
-    let mut _17: &impl Fn(&T);
-    let mut _18: (&T,);
-    let _19: ();
+    let mut _33: std::option::Option<&T>;
+    let mut _35: &impl Fn(&T);
+    let mut _36: (&T,);
+    let _37: ();
     scope 1 {
         debug iter => _12;
-        let _16: &T;
+        let _34: &T;
         scope 2 {
-            debug x => _16;
+            debug x => _34;
         }
         scope 18 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) {
-            let mut _13: &mut std::slice::Iter<'_, T>;
+            scope 19 (inlined <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back) {
+                let mut _13: *const T;
+                let mut _18: bool;
+                let mut _19: *const T;
+                let _32: &T;
+                let mut _38: &std::ptr::NonNull<T>;
+                let mut _39: &std::ptr::NonNull<T>;
+                scope 20 {
+                    let _14: std::ptr::NonNull<T>;
+                    let _20: usize;
+                    scope 21 {
+                    }
+                    scope 22 {
+                        scope 25 (inlined <NonNull<T> as PartialEq>::eq) {
+                            let mut _15: std::ptr::NonNull<T>;
+                            let mut _16: *mut T;
+                            let mut _17: *mut T;
+                            scope 26 (inlined NonNull::<T>::as_ptr) {
+                            }
+                            scope 27 (inlined NonNull::<T>::as_ptr) {
+                            }
+                        }
+                    }
+                    scope 23 (inlined std::ptr::const_ptr::<impl *const T>::addr) {
+                        scope 24 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) {
+                        }
+                    }
+                }
+                scope 28 (inlined std::slice::Iter::<'_, T>::next_back_unchecked) {
+                    let _26: std::ptr::NonNull<T>;
+                    let mut _40: &std::ptr::NonNull<T>;
+                    scope 29 (inlined std::slice::Iter::<'_, T>::pre_dec_end) {
+                        let mut _21: *mut *const T;
+                        let mut _22: *mut std::ptr::NonNull<T>;
+                        let mut _23: std::ptr::NonNull<T>;
+                        let mut _27: *mut *const T;
+                        let mut _28: *mut usize;
+                        let mut _29: usize;
+                        let mut _30: usize;
+                        scope 30 {
+                            scope 31 {
+                            }
+                            scope 32 {
+                                scope 35 (inlined NonNull::<T>::sub) {
+                                    scope 36 (inlined #[track_caller] core::num::<impl isize>::unchecked_neg) {
+                                        scope 37 (inlined core::ub_checks::check_language_ub) {
+                                            scope 38 (inlined core::ub_checks::check_language_ub::runtime) {
+                                            }
+                                        }
+                                    }
+                                    scope 39 (inlined NonNull::<T>::offset) {
+                                        let mut _24: *const T;
+                                        let mut _25: *const T;
+                                        scope 40 (inlined NonNull::<T>::as_ptr) {
+                                        }
+                                    }
+                                }
+                            }
+                            scope 33 (inlined std::ptr::mut_ptr::<impl *mut *const T>::cast::<usize>) {
+                            }
+                            scope 34 (inlined std::ptr::mut_ptr::<impl *mut *const T>::cast::<NonNull<T>>) {
+                            }
+                        }
+                    }
+                    scope 41 (inlined NonNull::<T>::as_ref::<'_>) {
+                        let _31: *const T;
+                        scope 42 (inlined NonNull::<T>::as_ptr) {
+                        }
+                        scope 43 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) {
+                        }
+                    }
+                }
+            }
         }
     }
     scope 3 (inlined core::slice::<impl [T]>::iter) {
@@ -105,53 +176,153 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
     }
 
     bb4: {
+        StorageLive(_33);
+        StorageLive(_20);
+        StorageLive(_19);
         StorageLive(_14);
-        StorageLive(_13);
-        _13 = &mut (_12.0: std::slice::Iter<'_, T>);
-        _14 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _13) -> [return: bb5, unwind: bb11];
+        StorageLive(_32);
+        StorageLive(_18);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb6];
     }
 
     bb5: {
+        StorageLive(_13);
+        _13 = copy ((_12.0: std::slice::Iter<'_, T>).1: *const T);
+        _14 = copy _13 as std::ptr::NonNull<T> (Transmute);
         StorageDead(_13);
-        _15 = discriminant(_14);
-        switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10];
+        StorageLive(_38);
+        // DBG: _38 = &((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>);
+        StorageLive(_39);
+        // DBG: _39 = &_14;
+        StorageLive(_16);
+        StorageLive(_15);
+        _15 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>);
+        _16 = copy _15 as *mut T (Transmute);
+        StorageDead(_15);
+        StorageLive(_17);
+        _17 = copy _14 as *mut T (Transmute);
+        _18 = Eq(copy _16, copy _17);
+        StorageDead(_17);
+        StorageDead(_16);
+        StorageDead(_39);
+        StorageDead(_38);
+        goto -> bb7;
     }
 
     bb6: {
-        StorageDead(_14);
-        StorageDead(_12);
-        drop(_2) -> [return: bb7, unwind continue];
+        _19 = copy ((_12.0: std::slice::Iter<'_, T>).1: *const T);
+        _20 = copy _19 as usize (Transmute);
+        _18 = Eq(copy _20, const 0_usize);
+        goto -> bb7;
     }
 
     bb7: {
-        return;
+        switchInt(move _18) -> [0: bb8, otherwise: bb17];
     }
 
     bb8: {
-        _16 = copy ((_14 as Some).0: &T);
-        StorageLive(_17);
-        _17 = &_2;
-        StorageLive(_18);
-        _18 = (copy _16,);
-        _19 = <impl Fn(&T) as Fn<(&T,)>>::call(move _17, move _18) -> [return: bb9, unwind: bb11];
+        StorageLive(_26);
+        StorageLive(_40);
+        StorageLive(_28);
+        StorageLive(_22);
+        StorageLive(_23);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb9, otherwise: bb12];
     }
 
     bb9: {
+        StorageLive(_21);
+        _21 = &raw mut ((_12.0: std::slice::Iter<'_, T>).1: *const T);
+        _22 = copy _21 as *mut std::ptr::NonNull<T> (PtrToPtr);
+        StorageDead(_21);
+        _23 = copy (*_22);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb10, otherwise: bb11];
+    }
+
+    bb10: {
+        StorageLive(_25);
+        StorageLive(_24);
+        _24 = copy _23 as *const T (Transmute);
+        _25 = Offset(copy _24, const -1_isize);
+        StorageDead(_24);
+        _23 = NonNull::<T> { pointer: copy _25 };
+        StorageDead(_25);
+        goto -> bb11;
+    }
+
+    bb11: {
+        (*_22) = move _23;
+        _26 = copy (*_22);
+        goto -> bb13;
+    }
+
+    bb12: {
+        StorageLive(_27);
+        _27 = &raw mut ((_12.0: std::slice::Iter<'_, T>).1: *const T);
+        _28 = copy _27 as *mut usize (PtrToPtr);
+        StorageDead(_27);
+        StorageLive(_30);
+        StorageLive(_29);
+        _29 = copy (*_28);
+        _30 = SubUnchecked(move _29, const 1_usize);
+        StorageDead(_29);
+        (*_28) = move _30;
+        StorageDead(_30);
+        _26 = copy ((_12.0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>);
+        goto -> bb13;
+    }
+
+    bb13: {
+        StorageDead(_23);
+        StorageDead(_22);
+        StorageDead(_28);
+        // DBG: _40 = &_26;
+        StorageLive(_31);
+        _31 = copy _26 as *const T (Transmute);
+        _32 = &(*_31);
+        StorageDead(_31);
+        StorageDead(_40);
+        StorageDead(_26);
+        _33 = Option::<&T>::Some(copy _32);
         StorageDead(_18);
-        StorageDead(_17);
+        StorageDead(_32);
         StorageDead(_14);
-        goto -> bb4;
+        StorageDead(_19);
+        StorageDead(_20);
+        _34 = copy ((_33 as Some).0: &T);
+        StorageLive(_35);
+        _35 = &_2;
+        StorageLive(_36);
+        _36 = (copy _34,);
+        _37 = <impl Fn(&T) as Fn<(&T,)>>::call(move _35, move _36) -> [return: bb14, unwind: bb15];
     }
 
-    bb10: {
-        unreachable;
+    bb14: {
+        StorageDead(_36);
+        StorageDead(_35);
+        StorageDead(_33);
+        goto -> bb4;
     }
 
-    bb11 (cleanup): {
-        drop(_2) -> [return: bb12, unwind terminate(cleanup)];
+    bb15 (cleanup): {
+        drop(_2) -> [return: bb16, unwind terminate(cleanup)];
     }
 
-    bb12 (cleanup): {
+    bb16 (cleanup): {
         resume;
     }
+
+    bb17: {
+        StorageDead(_18);
+        StorageDead(_32);
+        StorageDead(_14);
+        StorageDead(_19);
+        StorageDead(_20);
+        StorageDead(_33);
+        StorageDead(_12);
+        drop(_2) -> [return: bb18, unwind continue];
+    }
+
+    bb18: {
+        return;
+    }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir
index 9b510380b10..18a3d8e7c4a 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir
@@ -6,6 +6,8 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool {
     scope 1 (inlined <std::slice::Iter<'_, T> as ExactSizeIterator>::is_empty) {
         let mut _2: *const T;
         let mut _7: *const T;
+        let mut _9: &std::ptr::NonNull<T>;
+        let mut _10: &std::ptr::NonNull<T>;
         scope 2 {
             let _3: std::ptr::NonNull<T>;
             let _8: usize;
@@ -41,6 +43,10 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool {
         _2 = copy ((*_1).1: *const T);
         _3 = copy _2 as std::ptr::NonNull<T> (Transmute);
         StorageDead(_2);
+        StorageLive(_9);
+        // DBG: _9 = &((*_1).0: std::ptr::NonNull<T>);
+        StorageLive(_10);
+        // DBG: _10 = &_3;
         StorageLive(_5);
         StorageLive(_4);
         _4 = copy ((*_1).0: std::ptr::NonNull<T>);
@@ -51,6 +57,8 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool {
         _0 = Eq(copy _5, copy _6);
         StorageDead(_6);
         StorageDead(_5);
+        StorageDead(_10);
+        StorageDead(_9);
         goto -> bb3;
     }
 
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir
index 9b510380b10..18a3d8e7c4a 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir
@@ -6,6 +6,8 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool {
     scope 1 (inlined <std::slice::Iter<'_, T> as ExactSizeIterator>::is_empty) {
         let mut _2: *const T;
         let mut _7: *const T;
+        let mut _9: &std::ptr::NonNull<T>;
+        let mut _10: &std::ptr::NonNull<T>;
         scope 2 {
             let _3: std::ptr::NonNull<T>;
             let _8: usize;
@@ -41,6 +43,10 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool {
         _2 = copy ((*_1).1: *const T);
         _3 = copy _2 as std::ptr::NonNull<T> (Transmute);
         StorageDead(_2);
+        StorageLive(_9);
+        // DBG: _9 = &((*_1).0: std::ptr::NonNull<T>);
+        StorageLive(_10);
+        // DBG: _10 = &_3;
         StorageLive(_5);
         StorageLive(_4);
         _4 = copy ((*_1).0: std::ptr::NonNull<T>);
@@ -51,6 +57,8 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool {
         _0 = Eq(copy _5, copy _6);
         StorageDead(_6);
         StorageDead(_5);
+        StorageDead(_10);
+        StorageDead(_9);
         goto -> bb3;
     }
 
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir
index 78f96bf4195..590d4ac2c83 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-abort.mir
@@ -3,12 +3,199 @@
 fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut T> {
     debug it => _1;
     let mut _0: std::option::Option<&mut T>;
+    scope 1 (inlined <std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back) {
+        let mut _2: *mut T;
+        let mut _7: bool;
+        let mut _8: *mut T;
+        let mut _21: &mut T;
+        let mut _22: &std::ptr::NonNull<T>;
+        let mut _23: &std::ptr::NonNull<T>;
+        scope 2 {
+            let _3: std::ptr::NonNull<T>;
+            let _9: usize;
+            scope 3 {
+            }
+            scope 4 {
+                scope 7 (inlined <NonNull<T> as PartialEq>::eq) {
+                    let mut _4: std::ptr::NonNull<T>;
+                    let mut _5: *mut T;
+                    let mut _6: *mut T;
+                    scope 8 (inlined NonNull::<T>::as_ptr) {
+                    }
+                    scope 9 (inlined NonNull::<T>::as_ptr) {
+                    }
+                }
+            }
+            scope 5 (inlined std::ptr::mut_ptr::<impl *mut T>::addr) {
+                scope 6 (inlined std::ptr::mut_ptr::<impl *mut T>::cast::<()>) {
+                }
+            }
+        }
+        scope 10 (inlined std::slice::IterMut::<'_, T>::next_back_unchecked) {
+            let mut _15: std::ptr::NonNull<T>;
+            let mut _24: &mut std::ptr::NonNull<T>;
+            scope 11 (inlined std::slice::IterMut::<'_, T>::pre_dec_end) {
+                let mut _10: *mut *mut T;
+                let mut _11: *mut std::ptr::NonNull<T>;
+                let mut _12: std::ptr::NonNull<T>;
+                let mut _16: *mut *mut T;
+                let mut _17: *mut usize;
+                let mut _18: usize;
+                let mut _19: usize;
+                scope 12 {
+                    scope 13 {
+                    }
+                    scope 14 {
+                        scope 17 (inlined NonNull::<T>::sub) {
+                            scope 18 (inlined #[track_caller] core::num::<impl isize>::unchecked_neg) {
+                                scope 19 (inlined core::ub_checks::check_language_ub) {
+                                    scope 20 (inlined core::ub_checks::check_language_ub::runtime) {
+                                    }
+                                }
+                            }
+                            scope 21 (inlined NonNull::<T>::offset) {
+                                let mut _13: *const T;
+                                let mut _14: *const T;
+                                scope 22 (inlined NonNull::<T>::as_ptr) {
+                                }
+                            }
+                        }
+                    }
+                    scope 15 (inlined std::ptr::mut_ptr::<impl *mut *mut T>::cast::<usize>) {
+                    }
+                    scope 16 (inlined std::ptr::mut_ptr::<impl *mut *mut T>::cast::<NonNull<T>>) {
+                    }
+                }
+            }
+            scope 23 (inlined NonNull::<T>::as_mut::<'_>) {
+                let mut _20: *mut T;
+                scope 24 (inlined NonNull::<T>::as_ptr) {
+                }
+            }
+        }
+    }
 
     bb0: {
-        _0 = <std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back(move _1) -> [return: bb1, unwind unreachable];
+        StorageLive(_9);
+        StorageLive(_8);
+        StorageLive(_3);
+        StorageLive(_2);
+        StorageLive(_21);
+        StorageLive(_7);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
+        _2 = copy ((*_1).1: *mut T);
+        _3 = copy _2 as std::ptr::NonNull<T> (Transmute);
+        StorageLive(_22);
+        // DBG: _22 = &((*_1).0: std::ptr::NonNull<T>);
+        StorageLive(_23);
+        // DBG: _23 = &_3;
+        StorageLive(_5);
+        StorageLive(_4);
+        _4 = copy ((*_1).0: std::ptr::NonNull<T>);
+        _5 = copy _4 as *mut T (Transmute);
+        StorageDead(_4);
+        StorageLive(_6);
+        _6 = copy _3 as *mut T (Transmute);
+        _7 = Eq(copy _5, copy _6);
+        StorageDead(_6);
+        StorageDead(_5);
+        StorageDead(_23);
+        StorageDead(_22);
+        goto -> bb3;
+    }
+
+    bb2: {
+        _8 = copy ((*_1).1: *mut T);
+        _9 = copy _8 as usize (Transmute);
+        _7 = Eq(copy _9, const 0_usize);
+        goto -> bb3;
+    }
+
+    bb3: {
+        switchInt(move _7) -> [0: bb4, otherwise: bb10];
+    }
+
+    bb4: {
+        StorageLive(_15);
+        StorageLive(_24);
+        StorageLive(_17);
+        StorageLive(_11);
+        StorageLive(_12);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb8];
+    }
+
+    bb5: {
+        StorageLive(_10);
+        _10 = &raw mut ((*_1).1: *mut T);
+        _11 = copy _10 as *mut std::ptr::NonNull<T> (PtrToPtr);
+        StorageDead(_10);
+        _12 = copy (*_11);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb6, otherwise: bb7];
+    }
+
+    bb6: {
+        StorageLive(_14);
+        StorageLive(_13);
+        _13 = copy _12 as *const T (Transmute);
+        _14 = Offset(copy _13, const -1_isize);
+        StorageDead(_13);
+        _12 = NonNull::<T> { pointer: copy _14 };
+        StorageDead(_14);
+        goto -> bb7;
+    }
+
+    bb7: {
+        (*_11) = move _12;
+        _15 = copy (*_11);
+        goto -> bb9;
+    }
+
+    bb8: {
+        StorageLive(_16);
+        _16 = &raw mut ((*_1).1: *mut T);
+        _17 = copy _16 as *mut usize (PtrToPtr);
+        StorageDead(_16);
+        StorageLive(_19);
+        StorageLive(_18);
+        _18 = copy (*_17);
+        _19 = SubUnchecked(move _18, const 1_usize);
+        StorageDead(_18);
+        (*_17) = move _19;
+        StorageDead(_19);
+        _15 = copy ((*_1).0: std::ptr::NonNull<T>);
+        goto -> bb9;
+    }
+
+    bb9: {
+        StorageDead(_12);
+        StorageDead(_11);
+        StorageDead(_17);
+        // DBG: _24 = &_15;
+        StorageLive(_20);
+        _20 = copy _15 as *mut T (Transmute);
+        _21 = &mut (*_20);
+        StorageDead(_20);
+        StorageDead(_24);
+        StorageDead(_15);
+        _0 = Option::<&mut T>::Some(copy _21);
+        goto -> bb11;
+    }
+
+    bb10: {
+        _0 = const {transmute(0x0000000000000000): Option<&mut T>};
+        goto -> bb11;
+    }
+
+    bb11: {
+        StorageDead(_7);
+        StorageDead(_21);
+        StorageDead(_2);
+        StorageDead(_3);
+        StorageDead(_8);
+        StorageDead(_9);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir
index dfe5e206fad..590d4ac2c83 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir
@@ -3,12 +3,199 @@
 fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut T> {
     debug it => _1;
     let mut _0: std::option::Option<&mut T>;
+    scope 1 (inlined <std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back) {
+        let mut _2: *mut T;
+        let mut _7: bool;
+        let mut _8: *mut T;
+        let mut _21: &mut T;
+        let mut _22: &std::ptr::NonNull<T>;
+        let mut _23: &std::ptr::NonNull<T>;
+        scope 2 {
+            let _3: std::ptr::NonNull<T>;
+            let _9: usize;
+            scope 3 {
+            }
+            scope 4 {
+                scope 7 (inlined <NonNull<T> as PartialEq>::eq) {
+                    let mut _4: std::ptr::NonNull<T>;
+                    let mut _5: *mut T;
+                    let mut _6: *mut T;
+                    scope 8 (inlined NonNull::<T>::as_ptr) {
+                    }
+                    scope 9 (inlined NonNull::<T>::as_ptr) {
+                    }
+                }
+            }
+            scope 5 (inlined std::ptr::mut_ptr::<impl *mut T>::addr) {
+                scope 6 (inlined std::ptr::mut_ptr::<impl *mut T>::cast::<()>) {
+                }
+            }
+        }
+        scope 10 (inlined std::slice::IterMut::<'_, T>::next_back_unchecked) {
+            let mut _15: std::ptr::NonNull<T>;
+            let mut _24: &mut std::ptr::NonNull<T>;
+            scope 11 (inlined std::slice::IterMut::<'_, T>::pre_dec_end) {
+                let mut _10: *mut *mut T;
+                let mut _11: *mut std::ptr::NonNull<T>;
+                let mut _12: std::ptr::NonNull<T>;
+                let mut _16: *mut *mut T;
+                let mut _17: *mut usize;
+                let mut _18: usize;
+                let mut _19: usize;
+                scope 12 {
+                    scope 13 {
+                    }
+                    scope 14 {
+                        scope 17 (inlined NonNull::<T>::sub) {
+                            scope 18 (inlined #[track_caller] core::num::<impl isize>::unchecked_neg) {
+                                scope 19 (inlined core::ub_checks::check_language_ub) {
+                                    scope 20 (inlined core::ub_checks::check_language_ub::runtime) {
+                                    }
+                                }
+                            }
+                            scope 21 (inlined NonNull::<T>::offset) {
+                                let mut _13: *const T;
+                                let mut _14: *const T;
+                                scope 22 (inlined NonNull::<T>::as_ptr) {
+                                }
+                            }
+                        }
+                    }
+                    scope 15 (inlined std::ptr::mut_ptr::<impl *mut *mut T>::cast::<usize>) {
+                    }
+                    scope 16 (inlined std::ptr::mut_ptr::<impl *mut *mut T>::cast::<NonNull<T>>) {
+                    }
+                }
+            }
+            scope 23 (inlined NonNull::<T>::as_mut::<'_>) {
+                let mut _20: *mut T;
+                scope 24 (inlined NonNull::<T>::as_ptr) {
+                }
+            }
+        }
+    }
 
     bb0: {
-        _0 = <std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back(move _1) -> [return: bb1, unwind continue];
+        StorageLive(_9);
+        StorageLive(_8);
+        StorageLive(_3);
+        StorageLive(_2);
+        StorageLive(_21);
+        StorageLive(_7);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb2];
     }
 
     bb1: {
+        _2 = copy ((*_1).1: *mut T);
+        _3 = copy _2 as std::ptr::NonNull<T> (Transmute);
+        StorageLive(_22);
+        // DBG: _22 = &((*_1).0: std::ptr::NonNull<T>);
+        StorageLive(_23);
+        // DBG: _23 = &_3;
+        StorageLive(_5);
+        StorageLive(_4);
+        _4 = copy ((*_1).0: std::ptr::NonNull<T>);
+        _5 = copy _4 as *mut T (Transmute);
+        StorageDead(_4);
+        StorageLive(_6);
+        _6 = copy _3 as *mut T (Transmute);
+        _7 = Eq(copy _5, copy _6);
+        StorageDead(_6);
+        StorageDead(_5);
+        StorageDead(_23);
+        StorageDead(_22);
+        goto -> bb3;
+    }
+
+    bb2: {
+        _8 = copy ((*_1).1: *mut T);
+        _9 = copy _8 as usize (Transmute);
+        _7 = Eq(copy _9, const 0_usize);
+        goto -> bb3;
+    }
+
+    bb3: {
+        switchInt(move _7) -> [0: bb4, otherwise: bb10];
+    }
+
+    bb4: {
+        StorageLive(_15);
+        StorageLive(_24);
+        StorageLive(_17);
+        StorageLive(_11);
+        StorageLive(_12);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb8];
+    }
+
+    bb5: {
+        StorageLive(_10);
+        _10 = &raw mut ((*_1).1: *mut T);
+        _11 = copy _10 as *mut std::ptr::NonNull<T> (PtrToPtr);
+        StorageDead(_10);
+        _12 = copy (*_11);
+        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb6, otherwise: bb7];
+    }
+
+    bb6: {
+        StorageLive(_14);
+        StorageLive(_13);
+        _13 = copy _12 as *const T (Transmute);
+        _14 = Offset(copy _13, const -1_isize);
+        StorageDead(_13);
+        _12 = NonNull::<T> { pointer: copy _14 };
+        StorageDead(_14);
+        goto -> bb7;
+    }
+
+    bb7: {
+        (*_11) = move _12;
+        _15 = copy (*_11);
+        goto -> bb9;
+    }
+
+    bb8: {
+        StorageLive(_16);
+        _16 = &raw mut ((*_1).1: *mut T);
+        _17 = copy _16 as *mut usize (PtrToPtr);
+        StorageDead(_16);
+        StorageLive(_19);
+        StorageLive(_18);
+        _18 = copy (*_17);
+        _19 = SubUnchecked(move _18, const 1_usize);
+        StorageDead(_18);
+        (*_17) = move _19;
+        StorageDead(_19);
+        _15 = copy ((*_1).0: std::ptr::NonNull<T>);
+        goto -> bb9;
+    }
+
+    bb9: {
+        StorageDead(_12);
+        StorageDead(_11);
+        StorageDead(_17);
+        // DBG: _24 = &_15;
+        StorageLive(_20);
+        _20 = copy _15 as *mut T (Transmute);
+        _21 = &mut (*_20);
+        StorageDead(_20);
+        StorageDead(_24);
+        StorageDead(_15);
+        _0 = Option::<&mut T>::Some(copy _21);
+        goto -> bb11;
+    }
+
+    bb10: {
+        _0 = const {transmute(0x0000000000000000): Option<&mut T>};
+        goto -> bb11;
+    }
+
+    bb11: {
+        StorageDead(_7);
+        StorageDead(_21);
+        StorageDead(_2);
+        StorageDead(_3);
+        StorageDead(_8);
+        StorageDead(_9);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir
index cc0fce26149..e9ed932cbaf 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir
@@ -10,6 +10,9 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
         let mut _10: std::ptr::NonNull<T>;
         let mut _12: usize;
         let _14: &T;
+        let mut _15: &std::ptr::NonNull<T>;
+        let mut _16: &std::ptr::NonNull<T>;
+        let mut _17: &std::ptr::NonNull<T>;
         scope 2 {
             let _3: *const T;
             scope 3 {
@@ -67,7 +70,11 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
 
     bb1: {
         StorageLive(_7);
+        StorageLive(_15);
+        // DBG: _15 = &_2;
+        StorageLive(_16);
         _4 = copy _3 as std::ptr::NonNull<T> (Transmute);
+        // DBG: _16 = &_4;
         StorageLive(_5);
         _5 = copy _2 as *mut T (Transmute);
         StorageLive(_6);
@@ -79,6 +86,8 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
     }
 
     bb2: {
+        StorageDead(_16);
+        StorageDead(_15);
         StorageDead(_7);
         StorageLive(_10);
         StorageLive(_9);
@@ -94,6 +103,8 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
     }
 
     bb3: {
+        StorageDead(_16);
+        StorageDead(_15);
         _0 = const {transmute(0x0000000000000000): Option<&T>};
         StorageDead(_7);
         goto -> bb8;
@@ -116,10 +127,13 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
     }
 
     bb7: {
+        StorageLive(_17);
+        // DBG: _17 = &_2;
         StorageLive(_13);
         _13 = copy _2 as *const T (Transmute);
         _14 = &(*_13);
         StorageDead(_13);
+        StorageDead(_17);
         _0 = Option::<&T>::Some(copy _14);
         goto -> bb8;
     }
diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir
index cc0fce26149..e9ed932cbaf 100644
--- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir
@@ -10,6 +10,9 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
         let mut _10: std::ptr::NonNull<T>;
         let mut _12: usize;
         let _14: &T;
+        let mut _15: &std::ptr::NonNull<T>;
+        let mut _16: &std::ptr::NonNull<T>;
+        let mut _17: &std::ptr::NonNull<T>;
         scope 2 {
             let _3: *const T;
             scope 3 {
@@ -67,7 +70,11 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
 
     bb1: {
         StorageLive(_7);
+        StorageLive(_15);
+        // DBG: _15 = &_2;
+        StorageLive(_16);
         _4 = copy _3 as std::ptr::NonNull<T> (Transmute);
+        // DBG: _16 = &_4;
         StorageLive(_5);
         _5 = copy _2 as *mut T (Transmute);
         StorageLive(_6);
@@ -79,6 +86,8 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
     }
 
     bb2: {
+        StorageDead(_16);
+        StorageDead(_15);
         StorageDead(_7);
         StorageLive(_10);
         StorageLive(_9);
@@ -94,6 +103,8 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
     }
 
     bb3: {
+        StorageDead(_16);
+        StorageDead(_15);
         _0 = const {transmute(0x0000000000000000): Option<&T>};
         StorageDead(_7);
         goto -> bb8;
@@ -116,10 +127,13 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
     }
 
     bb7: {
+        StorageLive(_17);
+        // DBG: _17 = &_2;
         StorageLive(_13);
         _13 = copy _2 as *const T (Transmute);
         _14 = &(*_13);
         StorageDead(_13);
+        StorageDead(_17);
         _0 = Option::<&T>::Some(copy _14);
         goto -> bb8;
     }
diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir
index fe4e2deab87..79aa9c5ae1e 100644
--- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir
@@ -9,7 +9,7 @@ fn outer(_1: u8) -> u8 {
     }
 
     bb0: {
-        _2 = &_1;                        // scope 0 at $DIR/spans.rs:11:11: 11:13
+        // DBG: _2 = &_1;
         _0 = copy _1;                    // scope 1 at $DIR/spans.rs:15:5: 15:7
         return;                          // scope 0 at $DIR/spans.rs:12:2: 12:2
     }
diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir
index fe4e2deab87..79aa9c5ae1e 100644
--- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir
@@ -9,7 +9,7 @@ fn outer(_1: u8) -> u8 {
     }
 
     bb0: {
-        _2 = &_1;                        // scope 0 at $DIR/spans.rs:11:11: 11:13
+        // DBG: _2 = &_1;
         _0 = copy _1;                    // scope 1 at $DIR/spans.rs:15:5: 15:7
         return;                          // scope 0 at $DIR/spans.rs:12:2: 12:2
     }
diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir
index 2eee8a97db0..eebd4a7eb50 100644
--- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir
@@ -11,7 +11,9 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
             let mut _4: usize;
             scope 3 (inlined Vec::<u8>::as_ptr) {
                 debug self => _1;
+                let mut _6: &alloc::raw_vec::RawVec<u8>;
                 scope 4 (inlined alloc::raw_vec::RawVec::<u8>::ptr) {
+                    let mut _7: &alloc::raw_vec::RawVecInner;
                     scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::<u8>) {
                         scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::<u8>) {
                             let mut _2: std::ptr::NonNull<u8>;
@@ -55,8 +57,14 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
     bb0: {
         StorageLive(_2);
         StorageLive(_3);
+        StorageLive(_6);
+        // DBG: _6 = &((*_1).0: alloc::raw_vec::RawVec<u8>);
+        StorageLive(_7);
+        // DBG: _7 = &(((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner);
         _2 = copy (((((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
+        StorageDead(_7);
         _3 = copy _2 as *const u8 (Transmute);
+        StorageDead(_6);
         StorageLive(_4);
         _4 = copy ((*_1).1: usize);
         StorageLive(_5);
diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir
index 2eee8a97db0..eebd4a7eb50 100644
--- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir
@@ -11,7 +11,9 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
             let mut _4: usize;
             scope 3 (inlined Vec::<u8>::as_ptr) {
                 debug self => _1;
+                let mut _6: &alloc::raw_vec::RawVec<u8>;
                 scope 4 (inlined alloc::raw_vec::RawVec::<u8>::ptr) {
+                    let mut _7: &alloc::raw_vec::RawVecInner;
                     scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::<u8>) {
                         scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::<u8>) {
                             let mut _2: std::ptr::NonNull<u8>;
@@ -55,8 +57,14 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
     bb0: {
         StorageLive(_2);
         StorageLive(_3);
+        StorageLive(_6);
+        // DBG: _6 = &((*_1).0: alloc::raw_vec::RawVec<u8>);
+        StorageLive(_7);
+        // DBG: _7 = &(((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner);
         _2 = copy (((((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
+        StorageDead(_7);
         _3 = copy _2 as *const u8 (Transmute);
+        StorageDead(_6);
         StorageLive(_4);
         _4 = copy ((*_1).1: usize);
         StorageLive(_5);