about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_mir_transform/src/gvn.rs73
-rw-r--r--tests/mir-opt/const_allocation.main.GVN.after.32bit.mir4
-rw-r--r--tests/mir-opt/const_allocation.main.GVN.after.64bit.mir4
-rw-r--r--tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir4
-rw-r--r--tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir4
-rw-r--r--tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir4
-rw-r--r--tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir4
-rw-r--r--tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff6
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff12
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff12
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff12
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff12
-rw-r--r--tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff6
-rw-r--r--tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff6
-rw-r--r--tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff4
-rw-r--r--tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff4
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff6
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff6
-rw-r--r--tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff6
-rw-r--r--tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff6
-rw-r--r--tests/mir-opt/const_prop/ref_deref.main.GVN.diff6
-rw-r--r--tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff6
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff6
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff6
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff6
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff6
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff9
-rw-r--r--tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff9
-rw-r--r--tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff18
-rw-r--r--tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff18
-rw-r--r--tests/mir-opt/gvn.slices.GVN.panic-abort.diff12
-rw-r--r--tests/mir-opt/gvn.slices.GVN.panic-unwind.diff12
-rw-r--r--tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff30
-rw-r--r--tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff30
-rw-r--r--tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir16
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir2
-rw-r--r--tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir2
37 files changed, 168 insertions, 221 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs
index 2551c8aca88..dc3af038d80 100644
--- a/compiler/rustc_mir_transform/src/gvn.rs
+++ b/compiler/rustc_mir_transform/src/gvn.rs
@@ -84,7 +84,7 @@
 
 use rustc_const_eval::interpret::{intern_const_alloc_for_constprop, MemoryKind};
 use rustc_const_eval::interpret::{ImmTy, InterpCx, OpTy, Projectable, Scalar};
-use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
+use rustc_data_structures::fx::FxIndexSet;
 use rustc_data_structures::graph::dominators::Dominators;
 use rustc_hir::def::DefKind;
 use rustc_index::bit_set::BitSet;
@@ -99,6 +99,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeAndMut};
 use rustc_span::def_id::DefId;
 use rustc_span::DUMMY_SP;
 use rustc_target::abi::{self, Abi, Size, VariantIdx, FIRST_VARIANT};
+use smallvec::SmallVec;
 use std::borrow::Cow;
 
 use crate::dataflow_const_prop::DummyMachine;
@@ -238,14 +239,18 @@ struct VnState<'body, 'tcx> {
     local_decls: &'body LocalDecls<'tcx>,
     /// Value stored in each local.
     locals: IndexVec<Local, Option<VnIndex>>,
-    /// First local to be assigned that value.
-    rev_locals: FxHashMap<VnIndex, Vec<Local>>,
+    /// Locals that are assigned that value.
+    // This vector does not hold all the values of `VnIndex` that we create.
+    // It stops at the largest value created in the first phase of collecting assignments.
+    rev_locals: IndexVec<VnIndex, SmallVec<[Local; 1]>>,
     values: FxIndexSet<Value<'tcx>>,
     /// Values evaluated as constants if possible.
     evaluated: IndexVec<VnIndex, Option<OpTy<'tcx>>>,
     /// Counter to generate different values.
     /// This is an option to stop creating opaques during replacement.
     next_opaque: Option<usize>,
+    /// Cache the value of the `unsized_locals` features, to avoid fetching it repeatedly in a loop.
+    feature_unsized_locals: bool,
     ssa: &'body SsaLocals,
     dominators: &'body Dominators<BasicBlock>,
     reused_locals: BitSet<Local>,
@@ -265,10 +270,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
             param_env,
             local_decls,
             locals: IndexVec::from_elem(None, local_decls),
-            rev_locals: FxHashMap::default(),
+            rev_locals: IndexVec::default(),
             values: FxIndexSet::default(),
             evaluated: IndexVec::new(),
             next_opaque: Some(0),
+            feature_unsized_locals: tcx.features().unsized_locals,
             ssa,
             dominators,
             reused_locals: BitSet::new_empty(local_decls.len()),
@@ -316,10 +322,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
         self.locals[local] = Some(value);
 
         // Only register the value if its type is `Sized`, as we will emit copies of it.
-        let is_sized = !self.tcx.features().unsized_locals
+        let is_sized = !self.feature_unsized_locals
             || self.local_decls[local].ty.is_sized(self.tcx, self.param_env);
         if is_sized {
-            self.rev_locals.entry(value).or_default().push(local);
+            self.rev_locals.ensure_contains_elem(value, SmallVec::new);
+            self.rev_locals[value].push(local);
         }
     }
 
@@ -630,6 +637,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
         if place.is_indirect()
             && let Some(base) = self.locals[place.local]
             && let Some(new_local) = self.try_as_local(base, location)
+            && place.local != new_local
         {
             place.local = new_local;
             self.reused_locals.insert(new_local);
@@ -639,8 +647,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
 
         for i in 0..projection.len() {
             let elem = projection[i];
-            if let ProjectionElem::Index(idx) = elem
-                && let Some(idx) = self.locals[idx]
+            if let ProjectionElem::Index(idx_local) = elem
+                && let Some(idx) = self.locals[idx_local]
             {
                 if let Some(offset) = self.evaluated[idx].as_ref()
                     && let Ok(offset) = self.ecx.read_target_usize(offset)
@@ -648,9 +656,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
                 {
                     projection.to_mut()[i] =
                         ProjectionElem::ConstantIndex { offset, min_length, from_end: false };
-                } else if let Some(new_idx) = self.try_as_local(idx, location) {
-                    projection.to_mut()[i] = ProjectionElem::Index(new_idx);
-                    self.reused_locals.insert(new_idx);
+                } else if let Some(new_idx_local) = self.try_as_local(idx, location)
+                    && idx_local != new_idx_local
+                {
+                    projection.to_mut()[i] = ProjectionElem::Index(new_idx_local);
+                    self.reused_locals.insert(new_idx_local);
                 }
             }
         }
@@ -986,11 +996,11 @@ impl<'tcx> VnState<'_, 'tcx> {
     /// If there is a local which is assigned `index`, and its assignment strictly dominates `loc`,
     /// return it.
     fn try_as_local(&mut self, index: VnIndex, loc: Location) -> Option<Local> {
-        let other = self.rev_locals.get(&index)?;
+        let other = self.rev_locals.get(index)?;
         other
             .iter()
+            .find(|&&other| self.ssa.assignment_dominates(self.dominators, other, loc))
             .copied()
-            .find(|&other| self.ssa.assignment_dominates(self.dominators, other, loc))
     }
 }
 
@@ -1008,23 +1018,32 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
     }
 
     fn visit_statement(&mut self, stmt: &mut Statement<'tcx>, location: Location) {
-        if let StatementKind::Assign(box (_, ref mut rvalue)) = stmt.kind
+        if let StatementKind::Assign(box (ref mut lhs, ref mut rvalue)) = stmt.kind {
+            self.simplify_place_projection(lhs, location);
+
             // Do not try to simplify a constant, it's already in canonical shape.
-            && !matches!(rvalue, Rvalue::Use(Operand::Constant(_)))
-        {
-            if let Some(value) = self.simplify_rvalue(rvalue, location) {
-                if let Some(const_) = self.try_as_constant(value) {
-                    *rvalue = Rvalue::Use(Operand::Constant(Box::new(const_)));
-                } else if let Some(local) = self.try_as_local(value, location)
-                    && *rvalue != Rvalue::Use(Operand::Move(local.into()))
-                {
-                    *rvalue = Rvalue::Use(Operand::Copy(local.into()));
-                    self.reused_locals.insert(local);
-                }
+            if matches!(rvalue, Rvalue::Use(Operand::Constant(_))) {
+                return;
             }
-        } else {
-            self.super_statement(stmt, location);
+
+            let value = lhs
+                .as_local()
+                .and_then(|local| self.locals[local])
+                .or_else(|| self.simplify_rvalue(rvalue, location));
+            let Some(value) = value else { return };
+
+            if let Some(const_) = self.try_as_constant(value) {
+                *rvalue = Rvalue::Use(Operand::Constant(Box::new(const_)));
+            } else if let Some(local) = self.try_as_local(value, location)
+                && *rvalue != Rvalue::Use(Operand::Move(local.into()))
+            {
+                *rvalue = Rvalue::Use(Operand::Copy(local.into()));
+                self.reused_locals.insert(local);
+            }
+
+            return;
         }
+        self.super_statement(stmt, location);
     }
 }
 
diff --git a/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir b/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir
index f089c6741fe..10d99a13463 100644
--- a/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir
+++ b/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir
@@ -7,10 +7,10 @@ fn main() -> () {
 
     bb0: {
         StorageLive(_1);
-        nop;
+        StorageLive(_2);
         _2 = const {ALLOC9: &&[(Option<i32>, &[&str])]};
         _1 = (*_2);
-        nop;
+        StorageDead(_2);
         StorageDead(_1);
         _0 = const ();
         return;
diff --git a/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir b/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir
index 9cbbaf302be..2f23dbe9ee4 100644
--- a/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir
+++ b/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir
@@ -7,10 +7,10 @@ fn main() -> () {
 
     bb0: {
         StorageLive(_1);
-        nop;
+        StorageLive(_2);
         _2 = const {ALLOC9: &&[(Option<i32>, &[&str])]};
         _1 = (*_2);
-        nop;
+        StorageDead(_2);
         StorageDead(_1);
         _0 = const ();
         return;
diff --git a/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir b/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir
index dfa2d808128..6499e3676aa 100644
--- a/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir
+++ b/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir
@@ -7,10 +7,10 @@ fn main() -> () {
 
     bb0: {
         StorageLive(_1);
-        nop;
+        StorageLive(_2);
         _2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]};
         _1 = (*_2);
-        nop;
+        StorageDead(_2);
         StorageDead(_1);
         _0 = const ();
         return;
diff --git a/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir b/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir
index 02b66987169..02f5ebab847 100644
--- a/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir
+++ b/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir
@@ -7,10 +7,10 @@ fn main() -> () {
 
     bb0: {
         StorageLive(_1);
-        nop;
+        StorageLive(_2);
         _2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]};
         _1 = (*_2);
-        nop;
+        StorageDead(_2);
         StorageDead(_1);
         _0 = const ();
         return;
diff --git a/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir b/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir
index 386a55ee6fa..c95e696946a 100644
--- a/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir
+++ b/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir
@@ -7,10 +7,10 @@ fn main() -> () {
 
     bb0: {
         StorageLive(_1);
-        nop;
+        StorageLive(_2);
         _2 = const {ALLOC4: &&Packed};
         _1 = (*_2);
-        nop;
+        StorageDead(_2);
         StorageDead(_1);
         _0 = const ();
         return;
diff --git a/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir b/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir
index b9e98f8cd4c..198bc8bd07e 100644
--- a/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir
+++ b/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir
@@ -7,10 +7,10 @@ fn main() -> () {
 
     bb0: {
         StorageLive(_1);
-        nop;
+        StorageLive(_2);
         _2 = const {ALLOC2: &&Packed};
         _1 = (*_2);
-        nop;
+        StorageDead(_2);
         StorageDead(_1);
         _0 = const ();
         return;
diff --git a/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff b/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff
index 2285962fad1..a044cfc62e2 100644
--- a/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff
+++ b/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff
@@ -24,9 +24,8 @@
       bb0: {
           StorageLive(_2);
 -         _2 = (const 1_i32, const false);
--         StorageLive(_3);
 +         _2 = const (1_i32, false);
-+         nop;
+          StorageLive(_3);
           _3 = &raw mut (_2.1: bool);
 -         _2 = (const 1_i32, const false);
 +         _2 = const (1_i32, false);
@@ -42,9 +41,8 @@
           StorageDead(_6);
           _0 = _5;
 -         StorageDead(_5);
--         StorageDead(_3);
-+         nop;
 +         nop;
+          StorageDead(_3);
           StorageDead(_2);
           return;
       }
diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff
index a42f9291324..e1a93e31446 100644
--- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff
+++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff
@@ -22,18 +22,15 @@
       }
   
       bb0: {
--         StorageLive(_1);
-+         nop;
+          StorageLive(_1);
           StorageLive(_2);
--         StorageLive(_3);
-+         nop;
+          StorageLive(_3);
           _9 = const _;
           _3 = &(*_9);
           _2 = &raw const (*_3);
           _1 = move _2 as *const [i32] (PointerCoercion(Unsize));
           StorageDead(_2);
--         StorageDead(_3);
-+         nop;
+          StorageDead(_3);
           StorageLive(_5);
           StorageLive(_6);
           _6 = const 3_usize;
@@ -50,8 +47,7 @@
           StorageDead(_6);
           _0 = const ();
           StorageDead(_5);
--         StorageDead(_1);
-+         nop;
+          StorageDead(_1);
           return;
       }
   }
diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff
index f2d6de6621b..91999145efb 100644
--- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff
@@ -22,18 +22,15 @@
       }
   
       bb0: {
--         StorageLive(_1);
-+         nop;
+          StorageLive(_1);
           StorageLive(_2);
--         StorageLive(_3);
-+         nop;
+          StorageLive(_3);
           _9 = const _;
           _3 = &(*_9);
           _2 = &raw const (*_3);
           _1 = move _2 as *const [i32] (PointerCoercion(Unsize));
           StorageDead(_2);
--         StorageDead(_3);
-+         nop;
+          StorageDead(_3);
           StorageLive(_5);
           StorageLive(_6);
           _6 = const 3_usize;
@@ -50,8 +47,7 @@
           StorageDead(_6);
           _0 = const ();
           StorageDead(_5);
--         StorageDead(_1);
-+         nop;
+          StorageDead(_1);
           return;
       }
   }
diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff
index a42f9291324..e1a93e31446 100644
--- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff
+++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff
@@ -22,18 +22,15 @@
       }
   
       bb0: {
--         StorageLive(_1);
-+         nop;
+          StorageLive(_1);
           StorageLive(_2);
--         StorageLive(_3);
-+         nop;
+          StorageLive(_3);
           _9 = const _;
           _3 = &(*_9);
           _2 = &raw const (*_3);
           _1 = move _2 as *const [i32] (PointerCoercion(Unsize));
           StorageDead(_2);
--         StorageDead(_3);
-+         nop;
+          StorageDead(_3);
           StorageLive(_5);
           StorageLive(_6);
           _6 = const 3_usize;
@@ -50,8 +47,7 @@
           StorageDead(_6);
           _0 = const ();
           StorageDead(_5);
--         StorageDead(_1);
-+         nop;
+          StorageDead(_1);
           return;
       }
   }
diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff
index f2d6de6621b..91999145efb 100644
--- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff
@@ -22,18 +22,15 @@
       }
   
       bb0: {
--         StorageLive(_1);
-+         nop;
+          StorageLive(_1);
           StorageLive(_2);
--         StorageLive(_3);
-+         nop;
+          StorageLive(_3);
           _9 = const _;
           _3 = &(*_9);
           _2 = &raw const (*_3);
           _1 = move _2 as *const [i32] (PointerCoercion(Unsize));
           StorageDead(_2);
--         StorageDead(_3);
-+         nop;
+          StorageDead(_3);
           StorageLive(_5);
           StorageLive(_6);
           _6 = const 3_usize;
@@ -50,8 +47,7 @@
           StorageDead(_6);
           _0 = const ();
           StorageDead(_5);
--         StorageDead(_1);
-+         nop;
+          StorageDead(_1);
           return;
       }
   }
diff --git a/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff b/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff
index 7dd80d64360..b389080c497 100644
--- a/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff
+++ b/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff
@@ -22,12 +22,10 @@
 -         _1 = (const 1_i32,);
 +         _1 = const (1_i32,);
           StorageLive(_2);
--         StorageLive(_3);
-+         nop;
+          StorageLive(_3);
           _3 = &raw mut (_1.0: i32);
           (*_3) = const 5_i32;
--         StorageDead(_3);
-+         nop;
+          StorageDead(_3);
           _2 = const ();
           StorageDead(_2);
           StorageLive(_4);
diff --git a/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff b/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff
index c4b647d9d2d..c21869dece6 100644
--- a/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff
+++ b/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff
@@ -17,13 +17,11 @@
       bb0: {
           StorageLive(_1);
 -         _1 = (const 1_i32,);
--         StorageLive(_2);
 +         _1 = const (1_i32,);
-+         nop;
+          StorageLive(_2);
           _2 = &mut (_1.0: i32);
           (*_2) = const 5_i32;
--         StorageDead(_2);
-+         nop;
+          StorageDead(_2);
           StorageLive(_3);
           StorageLive(_4);
           _4 = (_1.0: i32);
diff --git a/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff
index fc0c8afd4cf..dfab4959516 100644
--- a/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff
+++ b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff
@@ -34,9 +34,5 @@
 + 
 + ALLOC1 (size: 2, align: 1) {
 +     01 02                                           │ ..
-+ }
-+ 
-+ ALLOC2 (size: 2, align: 1) {
-+     01 02                                           │ ..
   }
   
diff --git a/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff
index cf4089598e7..b6d69732316 100644
--- a/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff
@@ -34,9 +34,5 @@
 + 
 + ALLOC1 (size: 2, align: 1) {
 +     01 02                                           │ ..
-+ }
-+ 
-+ ALLOC2 (size: 2, align: 1) {
-+     01 02                                           │ ..
   }
   
diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff
index bc60546cd19..4ed7c985147 100644
--- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff
+++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff
@@ -19,17 +19,15 @@
       bb0: {
           StorageLive(_1);
 -         _1 = (const 42_i32, const 43_i32);
--         StorageLive(_2);
 +         _1 = const (42_i32, 43_i32);
-+         nop;
+          StorageLive(_2);
           _2 = &mut _1;
           ((*_2).1: i32) = const 99_i32;
           StorageLive(_3);
           _3 = _1;
           _0 = const ();
           StorageDead(_3);
--         StorageDead(_2);
-+         nop;
+          StorageDead(_2);
           StorageDead(_1);
           return;
       }
diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff
index d02c392f6bd..e113f43a56e 100644
--- a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff
+++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff
@@ -22,14 +22,12 @@
           _1 = const 42_u32;
           StorageLive(_2);
           StorageLive(_3);
--         StorageLive(_4);
-+         nop;
+          StorageLive(_4);
           _4 = const {ALLOC0: *mut u32};
           _3 = (*_4);
           _1 = move _3;
           StorageDead(_3);
--         StorageDead(_4);
-+         nop;
+          StorageDead(_4);
           _2 = const ();
           StorageDead(_2);
           StorageLive(_5);
diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff
index 425bc3ff6c1..4e79b3ad599 100644
--- a/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff
+++ b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff
@@ -16,14 +16,12 @@
 -         StorageLive(_1);
 +         nop;
           StorageLive(_2);
--         StorageLive(_3);
-+         nop;
+          StorageLive(_3);
           _3 = const _;
           _2 = &raw const (*_3);
           _1 = move _2 as usize (PointerExposeAddress);
           StorageDead(_2);
--         StorageDead(_3);
-+         nop;
+          StorageDead(_3);
           StorageLive(_4);
           StorageLive(_5);
           _5 = _1;
diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff
index e9360ab8d62..fdc459b457c 100644
--- a/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff
@@ -16,14 +16,12 @@
 -         StorageLive(_1);
 +         nop;
           StorageLive(_2);
--         StorageLive(_3);
-+         nop;
+          StorageLive(_3);
           _3 = const _;
           _2 = &raw const (*_3);
           _1 = move _2 as usize (PointerExposeAddress);
           StorageDead(_2);
--         StorageDead(_3);
-+         nop;
+          StorageDead(_3);
           StorageLive(_4);
           StorageLive(_5);
           _5 = _1;
diff --git a/tests/mir-opt/const_prop/ref_deref.main.GVN.diff b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff
index 8f9aa20524d..56cbd00025e 100644
--- a/tests/mir-opt/const_prop/ref_deref.main.GVN.diff
+++ b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff
@@ -13,14 +13,12 @@
   
       bb0: {
           StorageLive(_1);
--         StorageLive(_2);
-+         nop;
+          StorageLive(_2);
           _4 = const _;
           _2 = &(*_4);
 -         _1 = (*_2);
--         StorageDead(_2);
 +         _1 = const 4_i32;
-+         nop;
+          StorageDead(_2);
           _0 = const ();
           StorageDead(_1);
           return;
diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff
index 8d38888b7d6..d75c0c3b286 100644
--- a/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff
+++ b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff
@@ -13,14 +13,12 @@
   
       bb0: {
           StorageLive(_1);
--         StorageLive(_2);
-+         nop;
+          StorageLive(_2);
           _4 = const _;
           _2 = &((*_4).1: i32);
 -         _1 = (*_2);
--         StorageDead(_2);
 +         _1 = const 5_i32;
-+         nop;
+          StorageDead(_2);
           _0 = const ();
           StorageDead(_1);
           return;
diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff
index 8b2411e50ab..803be994d9a 100644
--- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff
+++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff
@@ -18,8 +18,7 @@
   
       bb0: {
           StorageLive(_1);
--         StorageLive(_2);
-+         nop;
+          StorageLive(_2);
           StorageLive(_3);
           StorageLive(_4);
           _9 = const _;
@@ -44,8 +43,7 @@
 +         _1 = (*_2)[1 of 2];
           StorageDead(_6);
           StorageDead(_4);
--         StorageDead(_2);
-+         nop;
+          StorageDead(_2);
           _0 = const ();
           StorageDead(_1);
           return;
diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff
index 9b20d243f87..2a20e3eca59 100644
--- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff
@@ -18,8 +18,7 @@
   
       bb0: {
           StorageLive(_1);
--         StorageLive(_2);
-+         nop;
+          StorageLive(_2);
           StorageLive(_3);
           StorageLive(_4);
           _9 = const _;
@@ -44,8 +43,7 @@
 +         _1 = (*_2)[1 of 2];
           StorageDead(_6);
           StorageDead(_4);
--         StorageDead(_2);
-+         nop;
+          StorageDead(_2);
           _0 = const ();
           StorageDead(_1);
           return;
diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff
index 8b2411e50ab..803be994d9a 100644
--- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff
+++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff
@@ -18,8 +18,7 @@
   
       bb0: {
           StorageLive(_1);
--         StorageLive(_2);
-+         nop;
+          StorageLive(_2);
           StorageLive(_3);
           StorageLive(_4);
           _9 = const _;
@@ -44,8 +43,7 @@
 +         _1 = (*_2)[1 of 2];
           StorageDead(_6);
           StorageDead(_4);
--         StorageDead(_2);
-+         nop;
+          StorageDead(_2);
           _0 = const ();
           StorageDead(_1);
           return;
diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff
index 9b20d243f87..2a20e3eca59 100644
--- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff
@@ -18,8 +18,7 @@
   
       bb0: {
           StorageLive(_1);
--         StorageLive(_2);
-+         nop;
+          StorageLive(_2);
           StorageLive(_3);
           StorageLive(_4);
           _9 = const _;
@@ -44,8 +43,7 @@
 +         _1 = (*_2)[1 of 2];
           StorageDead(_6);
           StorageDead(_4);
--         StorageDead(_2);
-+         nop;
+          StorageDead(_2);
           _0 = const ();
           StorageDead(_1);
           return;
diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff
index 93dfef96cf1..0ff31b1a981 100644
--- a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff
+++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff
@@ -13,13 +13,12 @@
   
       bb0: {
           StorageLive(_1);
--         StorageLive(_2);
+          StorageLive(_2);
 -         _2 = const 1_usize as &mut Never (Transmute);
-+         nop;
+-         _1 = &mut (*_2);
 +         _2 = const {0x1 as &mut Never};
-          _1 = &mut (*_2);
--         StorageDead(_2);
-+         nop;
++         _1 = const {0x1 as &mut Never};
+          StorageDead(_2);
           unreachable;
       }
   }
diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff
index 93dfef96cf1..0ff31b1a981 100644
--- a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff
+++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff
@@ -13,13 +13,12 @@
   
       bb0: {
           StorageLive(_1);
--         StorageLive(_2);
+          StorageLive(_2);
 -         _2 = const 1_usize as &mut Never (Transmute);
-+         nop;
+-         _1 = &mut (*_2);
 +         _2 = const {0x1 as &mut Never};
-          _1 = &mut (*_2);
--         StorageDead(_2);
-+         nop;
++         _1 = const {0x1 as &mut Never};
+          StorageDead(_2);
           unreachable;
       }
   }
diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff
index a587b1e6b1d..46bf13985da 100644
--- a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff
@@ -72,8 +72,7 @@
       bb2: {
           StorageDead(_7);
           StorageDead(_6);
--         StorageLive(_8);
-+         nop;
+          StorageLive(_8);
           _8 = &raw const (*_1);
           StorageLive(_9);
           StorageLive(_10);
@@ -93,8 +92,7 @@
       bb4: {
           StorageDead(_12);
           StorageDead(_11);
--         StorageLive(_13);
-+         nop;
+          StorageLive(_13);
           _13 = &raw mut (*_1);
           StorageLive(_14);
           StorageLive(_15);
@@ -114,8 +112,7 @@
       bb6: {
           StorageDead(_17);
           StorageDead(_16);
--         StorageLive(_18);
-+         nop;
+          StorageLive(_18);
           _18 = &(*_1);
           StorageLive(_19);
 -         StorageLive(_20);
@@ -191,12 +188,9 @@
           StorageDead(_32);
           StorageDead(_31);
           _0 = const ();
--         StorageDead(_18);
--         StorageDead(_13);
--         StorageDead(_8);
-+         nop;
-+         nop;
-+         nop;
+          StorageDead(_18);
+          StorageDead(_13);
+          StorageDead(_8);
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff
index 6fdda5e9988..3e731ead859 100644
--- a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff
@@ -72,8 +72,7 @@
       bb2: {
           StorageDead(_7);
           StorageDead(_6);
--         StorageLive(_8);
-+         nop;
+          StorageLive(_8);
           _8 = &raw const (*_1);
           StorageLive(_9);
           StorageLive(_10);
@@ -93,8 +92,7 @@
       bb4: {
           StorageDead(_12);
           StorageDead(_11);
--         StorageLive(_13);
-+         nop;
+          StorageLive(_13);
           _13 = &raw mut (*_1);
           StorageLive(_14);
           StorageLive(_15);
@@ -114,8 +112,7 @@
       bb6: {
           StorageDead(_17);
           StorageDead(_16);
--         StorageLive(_18);
-+         nop;
+          StorageLive(_18);
           _18 = &(*_1);
           StorageLive(_19);
 -         StorageLive(_20);
@@ -191,12 +188,9 @@
           StorageDead(_32);
           StorageDead(_31);
           _0 = const ();
--         StorageDead(_18);
--         StorageDead(_13);
--         StorageDead(_8);
-+         nop;
-+         nop;
-+         nop;
+          StorageDead(_18);
+          StorageDead(_13);
+          StorageDead(_8);
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff
index ec449980312..f3f9073909e 100644
--- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff
@@ -194,15 +194,13 @@
 -         _23 = move _21;
 +         _23 = const core::panicking::AssertKind::Eq;
           StorageLive(_24);
--         StorageLive(_25);
+          StorageLive(_25);
 -         _25 = &(*_15);
-+         nop;
 +         _25 = &(*_9);
           _24 = &(*_25);
           StorageLive(_26);
--         StorageLive(_27);
+          StorageLive(_27);
 -         _27 = &(*_16);
-+         nop;
 +         _27 = &(*_12);
           _26 = &(*_27);
           StorageLive(_28);
@@ -293,15 +291,13 @@
 -         _49 = move _47;
 +         _49 = const core::panicking::AssertKind::Eq;
           StorageLive(_50);
--         StorageLive(_51);
+          StorageLive(_51);
 -         _51 = &(*_41);
-+         nop;
 +         _51 = &(*_35);
           _50 = &(*_51);
           StorageLive(_52);
--         StorageLive(_53);
+          StorageLive(_53);
 -         _53 = &(*_42);
-+         nop;
 +         _53 = &(*_38);
           _52 = &(*_53);
           StorageLive(_54);
diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff
index 56a78ca8694..383152cce5e 100644
--- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff
@@ -194,15 +194,13 @@
 -         _23 = move _21;
 +         _23 = const core::panicking::AssertKind::Eq;
           StorageLive(_24);
--         StorageLive(_25);
+          StorageLive(_25);
 -         _25 = &(*_15);
-+         nop;
 +         _25 = &(*_9);
           _24 = &(*_25);
           StorageLive(_26);
--         StorageLive(_27);
+          StorageLive(_27);
 -         _27 = &(*_16);
-+         nop;
 +         _27 = &(*_12);
           _26 = &(*_27);
           StorageLive(_28);
@@ -293,15 +291,13 @@
 -         _49 = move _47;
 +         _49 = const core::panicking::AssertKind::Eq;
           StorageLive(_50);
--         StorageLive(_51);
+          StorageLive(_51);
 -         _51 = &(*_41);
-+         nop;
 +         _51 = &(*_35);
           _50 = &(*_51);
           StorageLive(_52);
--         StorageLive(_53);
+          StorageLive(_53);
 -         _53 = &(*_42);
-+         nop;
 +         _53 = &(*_38);
           _52 = &(*_53);
           StorageLive(_54);
diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff
index 0a747d3aef0..3ecd4650d81 100644
--- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff
@@ -757,8 +757,7 @@
       bb34: {
           StorageDead(_121);
           StorageDead(_120);
--         StorageLive(_126);
-+         nop;
+          StorageLive(_126);
           _126 = &_3;
           StorageLive(_127);
 -         StorageLive(_128);
@@ -799,8 +798,7 @@
       bb36: {
           StorageDead(_132);
           StorageDead(_131);
--         StorageLive(_135);
-+         nop;
+          StorageLive(_135);
           _135 = &mut _3;
           StorageLive(_136);
           StorageLive(_137);
@@ -835,8 +833,7 @@
           StorageDead(_141);
           StorageDead(_140);
           StorageLive(_144);
--         StorageLive(_145);
-+         nop;
+          StorageLive(_145);
           _145 = &raw const _3;
           StorageLive(_146);
           StorageLive(_147);
@@ -870,8 +867,7 @@
       bb40: {
           StorageDead(_151);
           StorageDead(_150);
--         StorageLive(_154);
-+         nop;
+          StorageLive(_154);
           _154 = &raw mut _3;
           StorageLive(_155);
           StorageLive(_156);
@@ -906,13 +902,10 @@
           StorageDead(_160);
           StorageDead(_159);
           _144 = const ();
--         StorageDead(_154);
--         StorageDead(_145);
-+         nop;
-+         nop;
+          StorageDead(_154);
+          StorageDead(_145);
           StorageDead(_144);
--         StorageLive(_163);
-+         nop;
+          StorageLive(_163);
           _163 = &_3;
           StorageLive(_164);
 -         StorageLive(_165);
@@ -954,12 +947,9 @@
           StorageDead(_169);
           StorageDead(_168);
           _0 = const ();
--         StorageDead(_163);
--         StorageDead(_135);
--         StorageDead(_126);
-+         nop;
-+         nop;
-+         nop;
+          StorageDead(_163);
+          StorageDead(_135);
+          StorageDead(_126);
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff
index 119a4d9bbe9..bf448280b1e 100644
--- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff
@@ -757,8 +757,7 @@
       bb34: {
           StorageDead(_121);
           StorageDead(_120);
--         StorageLive(_126);
-+         nop;
+          StorageLive(_126);
           _126 = &_3;
           StorageLive(_127);
 -         StorageLive(_128);
@@ -799,8 +798,7 @@
       bb36: {
           StorageDead(_132);
           StorageDead(_131);
--         StorageLive(_135);
-+         nop;
+          StorageLive(_135);
           _135 = &mut _3;
           StorageLive(_136);
           StorageLive(_137);
@@ -835,8 +833,7 @@
           StorageDead(_141);
           StorageDead(_140);
           StorageLive(_144);
--         StorageLive(_145);
-+         nop;
+          StorageLive(_145);
           _145 = &raw const _3;
           StorageLive(_146);
           StorageLive(_147);
@@ -870,8 +867,7 @@
       bb40: {
           StorageDead(_151);
           StorageDead(_150);
--         StorageLive(_154);
-+         nop;
+          StorageLive(_154);
           _154 = &raw mut _3;
           StorageLive(_155);
           StorageLive(_156);
@@ -906,13 +902,10 @@
           StorageDead(_160);
           StorageDead(_159);
           _144 = const ();
--         StorageDead(_154);
--         StorageDead(_145);
-+         nop;
-+         nop;
+          StorageDead(_154);
+          StorageDead(_145);
           StorageDead(_144);
--         StorageLive(_163);
-+         nop;
+          StorageLive(_163);
           _163 = &_3;
           StorageLive(_164);
 -         StorageLive(_165);
@@ -954,12 +947,9 @@
           StorageDead(_169);
           StorageDead(_168);
           _0 = const ();
--         StorageDead(_163);
--         StorageDead(_135);
--         StorageDead(_126);
-+         nop;
-+         nop;
-+         nop;
+          StorageDead(_163);
+          StorageDead(_135);
+          StorageDead(_126);
           return;
       }
   }
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 cc009e45e7e..7370da5629c 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
@@ -94,6 +94,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2
         StorageLive(_9);
         _9 = _6;
         _10 = &_9;
+        StorageLive(_11);
+        StorageLive(_12);
         _11 = _4;
         _12 = _9;
         StorageLive(_13);
@@ -103,6 +105,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2
         _15 = Le(move _13, move _14);
         StorageDead(_14);
         StorageDead(_13);
+        StorageDead(_12);
+        StorageDead(_11);
         switchInt(move _15) -> [0: bb1, otherwise: bb2];
     }
 
@@ -124,6 +128,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2
         StorageLive(_17);
         _17 = _5;
         _18 = &_17;
+        StorageLive(_19);
+        StorageLive(_20);
         _19 = _7;
         _20 = _17;
         StorageLive(_21);
@@ -133,6 +139,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2
         _23 = Le(move _21, move _22);
         StorageDead(_22);
         StorageDead(_21);
+        StorageDead(_20);
+        StorageDead(_19);
         switchInt(move _23) -> [0: bb3, otherwise: bb8];
     }
 
@@ -151,6 +159,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2
         StorageLive(_25);
         _25 = _4;
         _26 = &_25;
+        StorageLive(_27);
+        StorageLive(_28);
         _27 = _6;
         _28 = _25;
         StorageLive(_29);
@@ -160,6 +170,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2
         _31 = Le(move _29, move _30);
         StorageDead(_30);
         StorageDead(_29);
+        StorageDead(_28);
+        StorageDead(_27);
         switchInt(move _31) -> [0: bb5, otherwise: bb6];
     }
 
@@ -181,6 +193,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2
         StorageLive(_33);
         _33 = _7;
         _34 = &_33;
+        StorageLive(_35);
+        StorageLive(_36);
         _35 = _5;
         _36 = _33;
         StorageLive(_37);
@@ -190,6 +204,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2
         _0 = Le(move _37, move _38);
         StorageDead(_38);
         StorageDead(_37);
+        StorageDead(_36);
+        StorageDead(_35);
         StorageDead(_33);
         StorageDead(_34);
         StorageDead(_32);
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir
index a12411a0413..e4d9060d4cf 100644
--- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir
@@ -50,6 +50,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
     }
 
     bb0: {
+        StorageLive(_7);
         StorageLive(_4);
         StorageLive(_3);
         _3 = Len((*_1));
@@ -85,6 +86,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
 
     bb3: {
         StorageDead(_4);
+        StorageDead(_7);
         return;
     }
 }
diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir
index a12411a0413..e4d9060d4cf 100644
--- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir
+++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir
@@ -50,6 +50,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
     }
 
     bb0: {
+        StorageLive(_7);
         StorageLive(_4);
         StorageLive(_3);
         _3 = Len((*_1));
@@ -85,6 +86,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
 
     bb3: {
         StorageDead(_4);
+        StorageDead(_7);
         return;
     }
 }