about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_ast/src/ast.rs38
-rw-r--r--compiler/rustc_ast/src/mut_visit.rs2
-rw-r--r--compiler/rustc_ast/src/token.rs1
-rw-r--r--compiler/rustc_ast/src/util/classify.rs2
-rw-r--r--compiler/rustc_ast/src/util/parser.rs4
-rw-r--r--compiler/rustc_ast/src/visit.rs2
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs82
-rw-r--r--compiler/rustc_ast_passes/src/feature_gate.rs7
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state/expr.rs4
-rw-r--r--compiler/rustc_borrowck/src/borrowck_errors.rs3
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs21
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/region_name.rs14
-rw-r--r--compiler/rustc_borrowck/src/type_check/liveness/trace.rs43
-rw-r--r--compiler/rustc_builtin_macros/src/assert/context.rs2
-rw-r--r--compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs72
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs1
-rw-r--r--compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs3
-rw-r--r--compiler/rustc_const_eval/src/interpret/discriminant.rs11
-rw-r--r--compiler/rustc_const_eval/src/interpret/intern.rs36
-rw-r--r--compiler/rustc_const_eval/src/interpret/intrinsics.rs2
-rw-r--r--compiler/rustc_const_eval/src/interpret/memory.rs2
-rw-r--r--compiler/rustc_const_eval/src/interpret/mod.rs4
-rw-r--r--compiler/rustc_const_eval/src/interpret/operand.rs10
-rw-r--r--compiler/rustc_const_eval/src/interpret/step.rs2
-rw-r--r--compiler/rustc_feature/src/unstable.rs2
-rw-r--r--compiler/rustc_hir/src/hir.rs12
-rw-r--r--compiler/rustc_hir_typeck/src/check.rs19
-rw-r--r--compiler/rustc_hir_typeck/src/closure.rs3
-rw-r--r--compiler/rustc_infer/src/infer/opaque_types.rs2
-rw-r--r--compiler/rustc_infer/src/infer/outlives/for_liveness.rs121
-rw-r--r--compiler/rustc_infer/src/infer/outlives/mod.rs1
-rw-r--r--compiler/rustc_llvm/build.rs6
-rw-r--r--compiler/rustc_middle/src/mir/consts.rs50
-rw-r--r--compiler/rustc_middle/src/mir/terminator.rs12
-rw-r--r--compiler/rustc_middle/src/traits/select.rs4
-rw-r--r--compiler/rustc_middle/src/ty/context.rs11
-rw-r--r--compiler/rustc_middle/src/ty/print/mod.rs2
-rw-r--r--compiler/rustc_middle/src/ty/print/pretty.rs84
-rw-r--r--compiler/rustc_middle/src/ty/util.rs2
-rw-r--r--compiler/rustc_mir_transform/src/coroutine.rs143
-rw-r--r--compiler/rustc_mir_transform/src/dataflow_const_prop.rs8
-rw-r--r--compiler/rustc_mir_transform/src/gvn.rs759
-rw-r--r--compiler/rustc_mir_transform/src/inline.rs5
-rw-r--r--compiler/rustc_mir_transform/src/lib.rs2
-rw-r--r--compiler/rustc_mir_transform/src/simplify.rs2
-rw-r--r--compiler/rustc_parse/messages.ftl3
-rw-r--r--compiler/rustc_parse/src/errors.rs8
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs34
-rw-r--r--compiler/rustc_parse/src/parser/item.rs13
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs11
-rw-r--r--compiler/rustc_passes/src/hir_stats.rs4
-rw-r--r--compiler/rustc_resolve/src/def_collector.rs2
-rw-r--r--compiler/rustc_resolve/src/ident.rs6
-rw-r--r--compiler/rustc_resolve/src/late.rs20
-rw-r--r--compiler/rustc_session/src/options.rs1
-rw-r--r--compiler/rustc_smir/src/rustc_smir/mod.rs28
-rw-r--r--compiler/rustc_span/src/symbol.rs9
-rw-r--r--compiler/rustc_target/Cargo.toml2
-rw-r--r--compiler/rustc_target/src/spec/aarch64_apple_tvos_sim.rs31
-rw-r--r--compiler/rustc_target/src/spec/i586_unknown_netbsd.rs18
-rw-r--r--compiler/rustc_target/src/spec/mod.rs2
-rw-r--r--compiler/rustc_trait_selection/src/solve/assembly/mod.rs12
-rw-r--r--compiler/rustc_trait_selection/src/solve/project_goals/mod.rs35
-rw-r--r--compiler/rustc_trait_selection/src/solve/trait_goals.rs26
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs17
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs3
-rw-r--r--compiler/rustc_trait_selection/src/traits/project.rs48
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs23
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/confirmation.rs35
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/mod.rs6
-rw-r--r--compiler/rustc_trait_selection/src/traits/util.rs11
-rw-r--r--compiler/rustc_ty_utils/src/instance.rs13
-rw-r--r--compiler/stable_mir/src/mir/body.rs1
-rw-r--r--library/alloc/Cargo.toml2
-rw-r--r--library/alloc/src/alloc.rs9
-rw-r--r--library/alloc/src/collections/binary_heap/mod.rs6
-rw-r--r--library/alloc/src/raw_vec.rs2
-rw-r--r--library/alloc/src/vec/mod.rs11
m---------library/backtrace0
-rw-r--r--library/core/src/cell.rs4
-rw-r--r--library/core/src/intrinsics.rs2
-rw-r--r--library/core/src/lib.rs7
-rw-r--r--library/core/src/macros/mod.rs177
-rw-r--r--library/core/src/mem/mod.rs2
-rw-r--r--library/core/src/panic/unwind_safe.rs1
-rw-r--r--library/core/src/str/mod.rs6
-rw-r--r--library/std/Cargo.toml2
-rw-r--r--library/std/src/os/linux/fs.rs9
-rw-r--r--library/std/src/panicking.rs60
-rw-r--r--library/std/src/sys/unix/fd.rs24
-rw-r--r--library/std/src/sys/unix/fs.rs23
-rw-r--r--src/bootstrap/src/core/config/config.rs5
-rw-r--r--src/bootstrap/src/core/config/flags.rs3
-rw-r--r--src/bootstrap/src/lib.rs6
-rw-r--r--src/bootstrap/src/utils/exec.rs2
-rw-r--r--src/doc/rustc/src/platform-support.md2
-rw-r--r--src/doc/rustc/src/platform-support/apple-tvos.md4
-rw-r--r--src/etc/completions/x.py.fish15
-rw-r--r--src/etc/completions/x.py.ps115
-rw-r--r--src/etc/completions/x.py.sh30
-rw-r--r--src/etc/completions/x.py.zsh15
-rw-r--r--src/librustdoc/clean/mod.rs12
-rw-r--r--src/librustdoc/clean/simplify.rs2
-rw-r--r--src/librustdoc/clean/types.rs8
-rw-r--r--src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs2
-rw-r--r--src/tools/clippy/clippy_utils/src/ast_utils.rs2
-rw-r--r--src/tools/clippy/clippy_utils/src/sugg.rs2
-rw-r--r--src/tools/miri/tests/pass/function_pointers.rs5
-rw-r--r--src/tools/rustfmt/src/closures.rs2
-rw-r--r--src/tools/rustfmt/src/expr.rs8
-rw-r--r--src/tools/rustfmt/src/utils.rs2
-rw-r--r--src/tools/tidy/src/alphabetical.rs94
-rw-r--r--src/tools/tidy/src/alphabetical/tests.rs188
-rw-r--r--src/tools/tidy/src/lib.rs16
-rw-r--r--tests/assembly/closure-inherit-target-feature.rs1
-rw-r--r--tests/coverage-map/fn_sig_into_try.cov-map30
-rw-r--r--tests/coverage-map/status-quo/bad_counter_ids.cov-map98
-rw-r--r--tests/coverage-map/status-quo/bad_counter_ids.rs66
-rw-r--r--tests/coverage-map/status-quo/inline-dead.cov-map18
-rw-r--r--tests/coverage-map/status-quo/issue-84561.cov-map56
-rw-r--r--tests/coverage-map/status-quo/loops_branches.cov-map138
-rw-r--r--tests/coverage-map/status-quo/sort_groups.cov-map10
-rw-r--r--tests/coverage-map/status-quo/tight_inf_loop.cov-map6
-rw-r--r--tests/coverage-map/status-quo/while.cov-map10
-rw-r--r--tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff75
-rw-r--r--tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff121
-rw-r--r--tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff121
-rw-r--r--tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff308
-rw-r--r--tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff308
-rw-r--r--tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff66
-rw-r--r--tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff66
-rw-r--r--tests/mir-opt/gvn.cast.GVN.panic-abort.diff291
-rw-r--r--tests/mir-opt/gvn.cast.GVN.panic-unwind.diff291
-rw-r--r--tests/mir-opt/gvn.comparison.GVN.panic-abort.diff94
-rw-r--r--tests/mir-opt/gvn.comparison.GVN.panic-unwind.diff94
-rw-r--r--tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff32
-rw-r--r--tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff32
-rw-r--r--tests/mir-opt/gvn.duplicate_slice.GVN.panic-abort.diff38
-rw-r--r--tests/mir-opt/gvn.duplicate_slice.GVN.panic-unwind.diff38
-rw-r--r--tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff118
-rw-r--r--tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff118
-rw-r--r--tests/mir-opt/gvn.indirect_static.GVN.panic-abort.diff19
-rw-r--r--tests/mir-opt/gvn.indirect_static.GVN.panic-unwind.diff19
-rw-r--r--tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff136
-rw-r--r--tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff136
-rw-r--r--tests/mir-opt/gvn.references.GVN.panic-abort.diff79
-rw-r--r--tests/mir-opt/gvn.references.GVN.panic-unwind.diff101
-rw-r--r--tests/mir-opt/gvn.repeat.GVN.panic-abort.diff79
-rw-r--r--tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff79
-rw-r--r--tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff19
-rw-r--r--tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff19
-rw-r--r--tests/mir-opt/gvn.rs489
-rw-r--r--tests/mir-opt/gvn.slices.GVN.panic-abort.diff136
-rw-r--r--tests/mir-opt/gvn.slices.GVN.panic-unwind.diff136
-rw-r--r--tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff1091
-rw-r--r--tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff1091
-rw-r--r--tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff22
-rw-r--r--tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff22
-rw-r--r--tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff47
-rw-r--r--tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff47
-rw-r--r--tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff8
-rw-r--r--tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff8
-rw-r--r--tests/run-coverage/bad_counter_ids.coverage69
-rw-r--r--tests/run-coverage/bad_counter_ids.rs66
-rw-r--r--tests/ui/borrowck/alias-liveness/gat-static.rs29
-rw-r--r--tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.rs16
-rw-r--r--tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr16
-rw-r--r--tests/ui/borrowck/alias-liveness/higher-ranked.rs16
-rw-r--r--tests/ui/borrowck/alias-liveness/opaque-capture.rs17
-rw-r--r--tests/ui/borrowck/alias-liveness/opaque-type-param.rs14
-rw-r--r--tests/ui/borrowck/alias-liveness/opaque-type-param.stderr13
-rw-r--r--tests/ui/borrowck/alias-liveness/rpit-static.rs22
-rw-r--r--tests/ui/borrowck/alias-liveness/rpitit-static.rs18
-rw-r--r--tests/ui/borrowck/alias-liveness/rtn-static.rs23
-rw-r--r--tests/ui/borrowck/alias-liveness/rtn-static.stderr11
-rw-r--r--tests/ui/consts/const-eval/ub-enum.rs2
-rw-r--r--tests/ui/consts/const_discriminant.rs1
-rw-r--r--tests/ui/coroutine/gen_block.e2024.stderr19
-rw-r--r--tests/ui/coroutine/gen_block.none.stderr49
-rw-r--r--tests/ui/coroutine/gen_block.rs17
-rw-r--r--tests/ui/coroutine/gen_block_is_coro.rs18
-rw-r--r--tests/ui/coroutine/gen_block_is_coro.stderr21
-rw-r--r--tests/ui/coroutine/gen_block_is_iter.rs19
-rw-r--r--tests/ui/coroutine/gen_block_is_no_future.rs8
-rw-r--r--tests/ui/coroutine/gen_block_is_no_future.stderr12
-rw-r--r--tests/ui/coroutine/gen_block_iterate.rs35
-rw-r--r--tests/ui/coroutine/gen_block_move.fixed17
-rw-r--r--tests/ui/coroutine/gen_block_move.rs17
-rw-r--r--tests/ui/coroutine/gen_block_move.stderr30
-rw-r--r--tests/ui/coroutine/gen_fn.e2024.stderr10
-rw-r--r--tests/ui/coroutine/gen_fn.none.stderr8
-rw-r--r--tests/ui/coroutine/gen_fn.rs8
-rw-r--r--tests/ui/coroutine/self_referential_gen_block.rs17
-rw-r--r--tests/ui/coroutine/self_referential_gen_block.stderr11
-rw-r--r--tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr (renamed from tests/ui/feature-gates/feature-gate-coroutines.stderr)21
-rw-r--r--tests/ui/feature-gates/feature-gate-coroutines.none.stderr66
-rw-r--r--tests/ui/feature-gates/feature-gate-coroutines.rs12
-rw-r--r--tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr28
-rw-r--r--tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr9
-rw-r--r--tests/ui/feature-gates/feature-gate-gen_blocks.rs15
-rw-r--r--tests/ui/impl-trait/bivariant-lifetime-liveness.rs15
-rw-r--r--tests/ui/parser/issue-116781.rs8
-rw-r--r--tests/ui/parser/issue-116781.stderr16
203 files changed, 6934 insertions, 3159 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs
index e09ba03d881..146a4db200c 100644
--- a/compiler/rustc_ast/src/ast.rs
+++ b/compiler/rustc_ast/src/ast.rs
@@ -1235,7 +1235,7 @@ impl Expr {
             ExprKind::Closure(..) => ExprPrecedence::Closure,
             ExprKind::Block(..) => ExprPrecedence::Block,
             ExprKind::TryBlock(..) => ExprPrecedence::TryBlock,
-            ExprKind::Async(..) => ExprPrecedence::Async,
+            ExprKind::Gen(..) => ExprPrecedence::Gen,
             ExprKind::Await(..) => ExprPrecedence::Await,
             ExprKind::Assign(..) => ExprPrecedence::Assign,
             ExprKind::AssignOp(..) => ExprPrecedence::AssignOp,
@@ -1405,11 +1405,9 @@ pub enum ExprKind {
     Closure(Box<Closure>),
     /// A block (`'label: { ... }`).
     Block(P<Block>, Option<Label>),
-    /// An async block (`async move { ... }`).
-    ///
-    /// The async block used to have a `NodeId`, which was removed in favor of
-    /// using the parent `NodeId` of the parent `Expr`.
-    Async(CaptureBy, P<Block>),
+    /// An `async` block (`async move { ... }`),
+    /// or a `gen` block (`gen move { ... }`)
+    Gen(CaptureBy, P<Block>, GenBlockKind),
     /// An await expression (`my_future.await`). Span is of await keyword.
     Await(P<Expr>, Span),
 
@@ -1499,6 +1497,28 @@ pub enum ExprKind {
     Err,
 }
 
+/// Used to differentiate between `async {}` blocks and `gen {}` blocks.
+#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
+pub enum GenBlockKind {
+    Async,
+    Gen,
+}
+
+impl fmt::Display for GenBlockKind {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        self.modifier().fmt(f)
+    }
+}
+
+impl GenBlockKind {
+    pub fn modifier(&self) -> &'static str {
+        match self {
+            GenBlockKind::Async => "async",
+            GenBlockKind::Gen => "gen",
+        }
+    }
+}
+
 /// The explicit `Self` type in a "qualified path". The actual
 /// path, including the trait and the associated item, is stored
 /// separately. `position` represents the index of the associated
@@ -2363,6 +2383,12 @@ pub enum Async {
     No,
 }
 
+#[derive(Copy, Clone, Encodable, Decodable, Debug)]
+pub enum Gen {
+    Yes { span: Span, closure_id: NodeId, return_impl_trait_id: NodeId },
+    No,
+}
+
 impl Async {
     pub fn is_async(self) -> bool {
         matches!(self, Async::Yes { .. })
diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs
index ba2887146cf..0634ee970ec 100644
--- a/compiler/rustc_ast/src/mut_visit.rs
+++ b/compiler/rustc_ast/src/mut_visit.rs
@@ -1418,7 +1418,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
             vis.visit_block(blk);
             visit_opt(label, |label| vis.visit_label(label));
         }
-        ExprKind::Async(_capture_by, body) => {
+        ExprKind::Gen(_capture_by, body, _) => {
             vis.visit_block(body);
         }
         ExprKind::Await(expr, await_kw_span) => {
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs
index dd879a14567..914c97a14ac 100644
--- a/compiler/rustc_ast/src/token.rs
+++ b/compiler/rustc_ast/src/token.rs
@@ -197,6 +197,7 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool {
             kw::Continue,
             kw::False,
             kw::For,
+            kw::Gen,
             kw::If,
             kw::Let,
             kw::Loop,
diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs
index f9f1c0cf956..821fca6656c 100644
--- a/compiler/rustc_ast/src/util/classify.rs
+++ b/compiler/rustc_ast/src/util/classify.rs
@@ -46,7 +46,7 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> {
             Closure(closure) => {
                 expr = &closure.body;
             }
-            Async(..) | Block(..) | ForLoop(..) | If(..) | Loop(..) | Match(..) | Struct(..)
+            Gen(..) | Block(..) | ForLoop(..) | If(..) | Loop(..) | Match(..) | Struct(..)
             | TryBlock(..) | While(..) => break Some(expr),
             _ => break None,
         }
diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs
index d3e43e20235..13768c12017 100644
--- a/compiler/rustc_ast/src/util/parser.rs
+++ b/compiler/rustc_ast/src/util/parser.rs
@@ -285,7 +285,7 @@ pub enum ExprPrecedence {
     Block,
     TryBlock,
     Struct,
-    Async,
+    Gen,
     Await,
     Err,
 }
@@ -351,7 +351,7 @@ impl ExprPrecedence {
             | ExprPrecedence::ConstBlock
             | ExprPrecedence::Block
             | ExprPrecedence::TryBlock
-            | ExprPrecedence::Async
+            | ExprPrecedence::Gen
             | ExprPrecedence::Struct
             | ExprPrecedence::Err => PREC_PAREN,
         }
diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs
index e66c4a9ee26..e091961a144 100644
--- a/compiler/rustc_ast/src/visit.rs
+++ b/compiler/rustc_ast/src/visit.rs
@@ -872,7 +872,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
             walk_list!(visitor, visit_label, opt_label);
             visitor.visit_block(block);
         }
-        ExprKind::Async(_, body) => {
+        ExprKind::Gen(_, body, _) => {
             visitor.visit_block(body);
         }
         ExprKind::Await(expr, _) => visitor.visit_expr(expr),
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index b82f878ea87..d6fa74dc3e6 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -183,7 +183,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
                     self.arena.alloc_from_iter(arms.iter().map(|x| self.lower_arm(x))),
                     hir::MatchSource::Normal,
                 ),
-                ExprKind::Async(capture_clause, block) => self.make_async_expr(
+                ExprKind::Gen(capture_clause, block, GenBlockKind::Async) => self.make_async_expr(
                     *capture_clause,
                     e.id,
                     None,
@@ -317,6 +317,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
                         rest,
                     )
                 }
+                ExprKind::Gen(capture_clause, block, GenBlockKind::Gen) => self.make_gen_expr(
+                    *capture_clause,
+                    e.id,
+                    None,
+                    e.span,
+                    hir::CoroutineSource::Block,
+                    |this| this.with_new_scopes(|this| this.lower_block_expr(block)),
+                ),
                 ExprKind::Yield(opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()),
                 ExprKind::Err => hir::ExprKind::Err(
                     self.tcx.sess.delay_span_bug(e.span, "lowered ExprKind::Err"),
@@ -661,6 +669,57 @@ impl<'hir> LoweringContext<'_, 'hir> {
         }))
     }
 
+    /// Lower a `gen` construct to a generator that implements `Iterator`.
+    ///
+    /// This results in:
+    ///
+    /// ```text
+    /// static move? |()| -> () {
+    ///     <body>
+    /// }
+    /// ```
+    pub(super) fn make_gen_expr(
+        &mut self,
+        capture_clause: CaptureBy,
+        closure_node_id: NodeId,
+        _yield_ty: Option<hir::FnRetTy<'hir>>,
+        span: Span,
+        gen_kind: hir::CoroutineSource,
+        body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
+    ) -> hir::ExprKind<'hir> {
+        let output = hir::FnRetTy::DefaultReturn(self.lower_span(span));
+
+        // The closure/generator `FnDecl` takes a single (resume) argument of type `input_ty`.
+        let fn_decl = self.arena.alloc(hir::FnDecl {
+            inputs: &[],
+            output,
+            c_variadic: false,
+            implicit_self: hir::ImplicitSelfKind::None,
+            lifetime_elision_allowed: false,
+        });
+
+        let body = self.lower_body(move |this| {
+            this.coroutine_kind = Some(hir::CoroutineKind::Gen(gen_kind));
+
+            let res = body(this);
+            (&[], res)
+        });
+
+        // `static |()| -> () { body }`:
+        hir::ExprKind::Closure(self.arena.alloc(hir::Closure {
+            def_id: self.local_def_id(closure_node_id),
+            binder: hir::ClosureBinder::Default,
+            capture_clause,
+            bound_generic_params: &[],
+            fn_decl,
+            body,
+            fn_decl_span: self.lower_span(span),
+            fn_arg_span: None,
+            movability: Some(Movability::Movable),
+            constness: hir::Constness::NotConst,
+        }))
+    }
+
     /// Forwards a possible `#[track_caller]` annotation from `outer_hir_id` to
     /// `inner_hir_id` in case the `async_fn_track_caller` feature is enabled.
     pub(super) fn maybe_forward_track_caller(
@@ -712,7 +771,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
         let full_span = expr.span.to(await_kw_span);
         match self.coroutine_kind {
             Some(hir::CoroutineKind::Async(_)) => {}
-            Some(hir::CoroutineKind::Coroutine) | None => {
+            Some(hir::CoroutineKind::Coroutine) | Some(hir::CoroutineKind::Gen(_)) | None => {
                 self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
                     await_kw_span,
                     item_span: self.current_item,
@@ -936,8 +995,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
                 }
                 Some(movability)
             }
-            Some(hir::CoroutineKind::Async(_)) => {
-                panic!("non-`async` closure body turned `async` during lowering");
+            Some(hir::CoroutineKind::Gen(_)) | Some(hir::CoroutineKind::Async(_)) => {
+                panic!("non-`async`/`gen` closure body turned `async`/`gen` during lowering");
             }
             None => {
                 if movability == Movability::Static {
@@ -1445,11 +1504,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
 
     fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
         match self.coroutine_kind {
-            Some(hir::CoroutineKind::Coroutine) => {}
+            Some(hir::CoroutineKind::Gen(_)) => {}
             Some(hir::CoroutineKind::Async(_)) => {
                 self.tcx.sess.emit_err(AsyncCoroutinesNotSupported { span });
             }
-            None => self.coroutine_kind = Some(hir::CoroutineKind::Coroutine),
+            Some(hir::CoroutineKind::Coroutine) | None => {
+                if !self.tcx.features().coroutines {
+                    rustc_session::parse::feature_err(
+                        &self.tcx.sess.parse_sess,
+                        sym::coroutines,
+                        span,
+                        "yield syntax is experimental",
+                    )
+                    .emit();
+                }
+                self.coroutine_kind = Some(hir::CoroutineKind::Coroutine)
+            }
         }
 
         let expr =
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs
index 34532967d9e..a1bd2679137 100644
--- a/compiler/rustc_ast_passes/src/feature_gate.rs
+++ b/compiler/rustc_ast_passes/src/feature_gate.rs
@@ -554,7 +554,12 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
         "consider removing `for<...>`"
     );
     gate_all!(more_qualified_paths, "usage of qualified paths in this context is experimental");
-    gate_all!(coroutines, "yield syntax is experimental");
+    for &span in spans.get(&sym::yield_expr).iter().copied().flatten() {
+        if !span.at_least_rust_2024() {
+            gate_feature_post!(&visitor, coroutines, span, "yield syntax is experimental");
+        }
+    }
+    gate_all!(gen_blocks, "gen blocks are experimental");
     gate_all!(raw_ref_op, "raw address of syntax is experimental");
     gate_all!(const_trait_impl, "const trait impls are experimental");
     gate_all!(
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
index 269cb8f2380..e84af12d3f9 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs
@@ -445,8 +445,8 @@ impl<'a> State<'a> {
                 self.ibox(0);
                 self.print_block_with_attrs(blk, attrs);
             }
-            ast::ExprKind::Async(capture_clause, blk) => {
-                self.word_nbsp("async");
+            ast::ExprKind::Gen(capture_clause, blk, kind) => {
+                self.word_nbsp(kind.modifier());
                 self.print_capture_clause(*capture_clause);
                 // cbox/ibox in analogy to the `ExprKind::Block` arm above
                 self.cbox(0);
diff --git a/compiler/rustc_borrowck/src/borrowck_errors.rs b/compiler/rustc_borrowck/src/borrowck_errors.rs
index 2ceec1b5658..6731ef12306 100644
--- a/compiler/rustc_borrowck/src/borrowck_errors.rs
+++ b/compiler/rustc_borrowck/src/borrowck_errors.rs
@@ -373,11 +373,12 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
         span: Span,
         yield_span: Span,
     ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
+        let coroutine_kind = self.body.coroutine.as_ref().unwrap().coroutine_kind;
         let mut err = struct_span_err!(
             self,
             span,
             E0626,
-            "borrow may still be in use when coroutine yields",
+            "borrow may still be in use when {coroutine_kind:#} yields",
         );
         err.span_label(yield_span, "possible yield occurs here");
         err
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index 928c25d1061..247200dcd26 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -2491,11 +2491,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
 
         let (sugg_span, suggestion) = match tcx.sess.source_map().span_to_snippet(args_span) {
             Ok(string) => {
-                if string.starts_with("async ") {
-                    let pos = args_span.lo() + BytePos(6);
-                    (args_span.with_lo(pos).with_hi(pos), "move ")
-                } else if string.starts_with("async|") {
-                    let pos = args_span.lo() + BytePos(5);
+                let coro_prefix = if string.starts_with("async") {
+                    // `async` is 5 chars long. Not using `.len()` to avoid the cast from `usize` to `u32`
+                    Some(5)
+                } else if string.starts_with("gen") {
+                    // `gen` is 3 chars long
+                    Some(3)
+                } else {
+                    None
+                };
+                if let Some(n) = coro_prefix {
+                    let pos = args_span.lo() + BytePos(n);
                     (args_span.with_lo(pos).with_hi(pos), " move")
                 } else {
                     (args_span.shrink_to_lo(), "move ")
@@ -2505,6 +2511,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
         };
         let kind = match use_span.coroutine_kind() {
             Some(coroutine_kind) => match coroutine_kind {
+                CoroutineKind::Gen(kind) => match kind {
+                    CoroutineSource::Block => "gen block",
+                    CoroutineSource::Closure => "gen closure",
+                    _ => bug!("gen block/closure expected, but gen function found."),
+                },
                 CoroutineKind::Async(async_kind) => match async_kind {
                     CoroutineSource::Block => "async block",
                     CoroutineSource::Closure => "async closure",
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs
index e630ac7c4fa..d38cfbc54d7 100644
--- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs
@@ -698,6 +698,20 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
                             " of async function"
                         }
                     },
+                    Some(hir::CoroutineKind::Gen(gen)) => match gen {
+                        hir::CoroutineSource::Block => " of gen block",
+                        hir::CoroutineSource::Closure => " of gen closure",
+                        hir::CoroutineSource::Fn => {
+                            let parent_item =
+                                hir.get_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
+                            let output = &parent_item
+                                .fn_decl()
+                                .expect("coroutine lowered from gen fn should be in fn")
+                                .output;
+                            span = output.span();
+                            " of gen function"
+                        }
+                    },
                     Some(hir::CoroutineKind::Coroutine) => " of coroutine",
                     None => " of closure",
                 };
diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
index cfefe0a3e65..e616449ccd4 100644
--- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
+++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
@@ -3,6 +3,7 @@ use rustc_data_structures::graph::WithSuccessors;
 use rustc_index::bit_set::{HybridBitSet, SparseBitMatrix};
 use rustc_index::interval::IntervalSet;
 use rustc_infer::infer::canonical::QueryRegionConstraints;
+use rustc_infer::infer::outlives::for_liveness;
 use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
 use rustc_middle::traits::query::DropckOutlivesResult;
 use rustc_middle::ty::{RegionVid, Ty, TyCtxt, TypeVisitable, TypeVisitableExt};
@@ -601,34 +602,36 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
             values::location_set_str(elements, live_at.iter()),
         );
 
-        let tcx = typeck.tcx();
-        let borrowck_context = &mut typeck.borrowck_context;
-
         // When using `-Zpolonius=next`, we want to record the loans that flow into this value's
         // regions as being live at the given `live_at` points: this will be used to compute the
         // location where a loan goes out of scope.
-        let num_loans = borrowck_context.borrow_set.len();
-        let mut value_loans = HybridBitSet::new_empty(num_loans);
-
-        tcx.for_each_free_region(&value, |live_region| {
-            let live_region_vid = borrowck_context.universal_regions.to_region_vid(live_region);
-
-            borrowck_context
-                .constraints
-                .liveness_constraints
-                .add_elements(live_region_vid, live_at);
-
-            // There can only be inflowing loans for this region when we are using
-            // `-Zpolonius=next`.
-            if let Some(inflowing) = inflowing_loans.row(live_region_vid) {
-                value_loans.union(inflowing);
-            }
+        let num_loans = typeck.borrowck_context.borrow_set.len();
+        let value_loans = &mut HybridBitSet::new_empty(num_loans);
+
+        value.visit_with(&mut for_liveness::FreeRegionsVisitor {
+            tcx: typeck.tcx(),
+            param_env: typeck.param_env,
+            op: |r| {
+                let live_region_vid = typeck.borrowck_context.universal_regions.to_region_vid(r);
+
+                typeck
+                    .borrowck_context
+                    .constraints
+                    .liveness_constraints
+                    .add_elements(live_region_vid, live_at);
+
+                // There can only be inflowing loans for this region when we are using
+                // `-Zpolonius=next`.
+                if let Some(inflowing) = inflowing_loans.row(live_region_vid) {
+                    value_loans.union(inflowing);
+                }
+            },
         });
 
         // Record the loans reaching the value.
         if !value_loans.is_empty() {
             for point in live_at.iter() {
-                borrowck_context.live_loans.union_row(point, &value_loans);
+                typeck.borrowck_context.live_loans.union_row(point, value_loans);
             }
         }
     }
diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs
index 6733b9e56ad..2a4bfe9e200 100644
--- a/compiler/rustc_builtin_macros/src/assert/context.rs
+++ b/compiler/rustc_builtin_macros/src/assert/context.rs
@@ -294,7 +294,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
             // sync with the `rfc-2011-nicer-assert-messages/all-expr-kinds.rs` test.
             ExprKind::Assign(_, _, _)
             | ExprKind::AssignOp(_, _, _)
-            | ExprKind::Async(_, _)
+            | ExprKind::Gen(_, _, _)
             | ExprKind::Await(_, _)
             | ExprKind::Block(_, _)
             | ExprKind::Break(_, _)
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
index 93a8a4b1d5e..cd67fafb8e4 100644
--- a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
+++ b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
@@ -102,7 +102,7 @@ impl<'tcx> FunctionCoverageCollector<'tcx> {
         // have zero as both of their operands, and will therefore always have
         // a value of zero. Other expressions that refer to these as operands
         // can have those operands replaced with `CovTerm::Zero`.
-        let mut zero_expressions = FxIndexSet::default();
+        let mut zero_expressions = ZeroExpressions::default();
 
         // Simplify a copy of each expression based on lower-numbered expressions,
         // and then update the set of always-zero expressions if necessary.
@@ -131,16 +131,16 @@ impl<'tcx> FunctionCoverageCollector<'tcx> {
                 )
             };
 
-            // If an operand refers to an expression that is always zero, then
-            // that operand can be replaced with `CovTerm::Zero`.
-            let maybe_set_operand_to_zero = |operand: &mut CovTerm| match *operand {
-                CovTerm::Expression(id) => {
+            // If an operand refers to a counter or expression that is always
+            // zero, then that operand can be replaced with `CovTerm::Zero`.
+            let maybe_set_operand_to_zero = |operand: &mut CovTerm| {
+                if let CovTerm::Expression(id) = *operand {
                     assert_operand_expression_is_lower(id);
-                    if zero_expressions.contains(&id) {
-                        *operand = CovTerm::Zero;
-                    }
                 }
-                _ => (),
+
+                if is_zero_term(&self.counters_seen, &zero_expressions, *operand) {
+                    *operand = CovTerm::Zero;
+                }
             };
             maybe_set_operand_to_zero(&mut lhs);
             maybe_set_operand_to_zero(&mut rhs);
@@ -159,7 +159,7 @@ impl<'tcx> FunctionCoverageCollector<'tcx> {
             }
         }
 
-        ZeroExpressions(zero_expressions)
+        zero_expressions
     }
 
     pub(crate) fn into_finished(self) -> FunctionCoverage<'tcx> {
@@ -205,19 +205,14 @@ impl<'tcx> FunctionCoverage<'tcx> {
         // thing on the Rust side unless we're confident we can do much better.
         // (See `CounterExpressionsMinimizer` in `CoverageMappingWriter.cpp`.)
 
-        let counter_from_operand = |operand: CovTerm| match operand {
-            CovTerm::Expression(id) if self.zero_expressions.contains(id) => Counter::ZERO,
-            _ => Counter::from_term(operand),
-        };
-
         self.function_coverage_info.expressions.iter().map(move |&Expression { lhs, op, rhs }| {
             CounterExpression {
-                lhs: counter_from_operand(lhs),
+                lhs: self.counter_for_term(lhs),
                 kind: match op {
                     Op::Add => ExprKind::Add,
                     Op::Subtract => ExprKind::Subtract,
                 },
-                rhs: counter_from_operand(rhs),
+                rhs: self.counter_for_term(rhs),
             }
         })
     }
@@ -227,34 +222,49 @@ impl<'tcx> FunctionCoverage<'tcx> {
     pub(crate) fn counter_regions(
         &self,
     ) -> impl Iterator<Item = (Counter, &CodeRegion)> + ExactSizeIterator {
-        // Historically, mappings were stored directly in counter/expression
-        // statements in MIR, and MIR optimizations would sometimes remove them.
-        // That's mostly no longer true, so now we detect cases where that would
-        // have happened, and zero out the corresponding mappings here instead.
-        let counter_for_term = move |term: CovTerm| {
-            let force_to_zero = match term {
-                CovTerm::Counter(id) => !self.counters_seen.contains(id),
-                CovTerm::Expression(id) => self.zero_expressions.contains(id),
-                CovTerm::Zero => false,
-            };
-            if force_to_zero { Counter::ZERO } else { Counter::from_term(term) }
-        };
-
         self.function_coverage_info.mappings.iter().map(move |mapping| {
             let &Mapping { term, ref code_region } = mapping;
-            let counter = counter_for_term(term);
+            let counter = self.counter_for_term(term);
             (counter, code_region)
         })
     }
+
+    fn counter_for_term(&self, term: CovTerm) -> Counter {
+        if is_zero_term(&self.counters_seen, &self.zero_expressions, term) {
+            Counter::ZERO
+        } else {
+            Counter::from_term(term)
+        }
+    }
 }
 
 /// Set of expression IDs that are known to always evaluate to zero.
 /// Any mapping or expression operand that refers to these expressions can have
 /// that reference replaced with a constant zero value.
+#[derive(Default)]
 struct ZeroExpressions(FxIndexSet<ExpressionId>);
 
 impl ZeroExpressions {
+    fn insert(&mut self, id: ExpressionId) {
+        self.0.insert(id);
+    }
+
     fn contains(&self, id: ExpressionId) -> bool {
         self.0.contains(&id)
     }
 }
+
+/// Returns `true` if the given term is known to have a value of zero, taking
+/// into account knowledge of which counters are unused and which expressions
+/// are always zero.
+fn is_zero_term(
+    counters_seen: &BitSet<CounterId>,
+    zero_expressions: &ZeroExpressions,
+    term: CovTerm,
+) -> bool {
+    match term {
+        CovTerm::Zero => true,
+        CovTerm::Counter(id) => !counters_seen.contains(id),
+        CovTerm::Expression(id) => zero_expressions.contains(id),
+    }
+}
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index d8c89f5947f..bcbb75d9599 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2880,6 +2880,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
     }
 
     let sdk_name = match (arch.as_ref(), os.as_ref()) {
+        ("aarch64", "tvos") if llvm_target.ends_with("-simulator") => "appletvsimulator",
         ("aarch64", "tvos") => "appletvos",
         ("x86_64", "tvos") => "appletvsimulator",
         ("arm", "ios") => "iphoneos",
diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
index 5900c764073..1a85eb8dd79 100644
--- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
+++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
@@ -560,6 +560,9 @@ pub fn push_item_name(tcx: TyCtxt<'_>, def_id: DefId, qualified: bool, output: &
 
 fn coroutine_kind_label(coroutine_kind: Option<CoroutineKind>) -> &'static str {
     match coroutine_kind {
+        Some(CoroutineKind::Gen(CoroutineSource::Block)) => "gen_block",
+        Some(CoroutineKind::Gen(CoroutineSource::Closure)) => "gen_closure",
+        Some(CoroutineKind::Gen(CoroutineSource::Fn)) => "gen_fn",
         Some(CoroutineKind::Async(CoroutineSource::Block)) => "async_block",
         Some(CoroutineKind::Async(CoroutineSource::Closure)) => "async_closure",
         Some(CoroutineKind::Async(CoroutineSource::Fn)) => "async_fn",
diff --git a/compiler/rustc_const_eval/src/interpret/discriminant.rs b/compiler/rustc_const_eval/src/interpret/discriminant.rs
index 8dab45d65ee..fd173670374 100644
--- a/compiler/rustc_const_eval/src/interpret/discriminant.rs
+++ b/compiler/rustc_const_eval/src/interpret/discriminant.rs
@@ -1,7 +1,8 @@
 //! Functions for reading and writing discriminants of multi-variant layouts (enums and coroutines).
 
-use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
-use rustc_middle::{mir, ty};
+use rustc_middle::mir;
+use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt};
+use rustc_middle::ty::{self, Ty};
 use rustc_target::abi::{self, TagEncoding};
 use rustc_target::abi::{VariantIdx, Variants};
 
@@ -244,11 +245,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
 
     pub fn discriminant_for_variant(
         &self,
-        layout: TyAndLayout<'tcx>,
+        ty: Ty<'tcx>,
         variant: VariantIdx,
     ) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> {
-        let discr_layout = self.layout_of(layout.ty.discriminant_ty(*self.tcx))?;
-        let discr_value = match layout.ty.discriminant_for_variant(*self.tcx, variant) {
+        let discr_layout = self.layout_of(ty.discriminant_ty(*self.tcx))?;
+        let discr_value = match ty.discriminant_for_variant(*self.tcx, variant) {
             Some(discr) => {
                 // This type actually has discriminants.
                 assert_eq!(discr.ty, discr_layout.ty);
diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs
index fd89e34204f..3d90e95c09c 100644
--- a/compiler/rustc_const_eval/src/interpret/intern.rs
+++ b/compiler/rustc_const_eval/src/interpret/intern.rs
@@ -450,6 +450,42 @@ pub fn intern_const_alloc_recursive<
     Ok(())
 }
 
+/// Intern `ret`. This function assumes that `ret` references no other allocation.
+#[instrument(level = "debug", skip(ecx))]
+pub fn intern_const_alloc_for_constprop<
+    'mir,
+    'tcx: 'mir,
+    T,
+    M: CompileTimeMachine<'mir, 'tcx, T>,
+>(
+    ecx: &mut InterpCx<'mir, 'tcx, M>,
+    alloc_id: AllocId,
+) -> InterpResult<'tcx, ()> {
+    // Move allocation to `tcx`.
+    let Some((_, mut alloc)) = ecx.memory.alloc_map.remove(&alloc_id) else {
+        // Pointer not found in local memory map. It is either a pointer to the global
+        // map, or dangling.
+        if ecx.tcx.try_get_global_alloc(alloc_id).is_none() {
+            throw_ub!(DeadLocal)
+        }
+        // The constant is already in global memory. Do nothing.
+        return Ok(());
+    };
+
+    alloc.mutability = Mutability::Not;
+
+    // We are not doing recursive interning, so we don't currently support provenance.
+    // (If this assertion ever triggers, we should just implement a
+    // proper recursive interning loop.)
+    assert!(alloc.provenance().ptrs().is_empty());
+
+    // Link the alloc id to the actual allocation
+    let alloc = ecx.tcx.mk_const_alloc(alloc);
+    ecx.tcx.set_alloc_id_memory(alloc_id, alloc);
+
+    Ok(())
+}
+
 impl<'mir, 'tcx: 'mir, M: super::intern::CompileTimeMachine<'mir, 'tcx, !>>
     InterpCx<'mir, 'tcx, M>
 {
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
index c97207a61ac..c48857fcf3c 100644
--- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs
+++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
@@ -218,7 +218,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             sym::discriminant_value => {
                 let place = self.deref_pointer(&args[0])?;
                 let variant = self.read_discriminant(&place)?;
-                let discr = self.discriminant_for_variant(place.layout, variant)?;
+                let discr = self.discriminant_for_variant(place.layout.ty, variant)?;
                 self.write_immediate(*discr, dest)?;
             }
             sym::exact_div => {
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs
index d7c7e279849..16905e93bf1 100644
--- a/compiler/rustc_const_eval/src/interpret/memory.rs
+++ b/compiler/rustc_const_eval/src/interpret/memory.rs
@@ -1011,7 +1011,7 @@ impl<'tcx, 'a, Prov: Provenance, Extra, Bytes: AllocBytes> AllocRef<'a, 'tcx, Pr
     }
 
     /// Returns whether the allocation has provenance anywhere in the range of the `AllocRef`.
-    pub(crate) fn has_provenance(&self) -> bool {
+    pub fn has_provenance(&self) -> bool {
         !self.alloc.provenance().range_empty(self.range, &self.tcx)
     }
 }
diff --git a/compiler/rustc_const_eval/src/interpret/mod.rs b/compiler/rustc_const_eval/src/interpret/mod.rs
index 13664456987..7d286d103ad 100644
--- a/compiler/rustc_const_eval/src/interpret/mod.rs
+++ b/compiler/rustc_const_eval/src/interpret/mod.rs
@@ -21,7 +21,9 @@ mod visitor;
 pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in one place: here
 
 pub use self::eval_context::{Frame, FrameInfo, InterpCx, StackPopCleanup};
-pub use self::intern::{intern_const_alloc_recursive, InternKind};
+pub use self::intern::{
+    intern_const_alloc_for_constprop, intern_const_alloc_recursive, InternKind,
+};
 pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, StackPopJump};
 pub use self::memory::{AllocKind, AllocRef, AllocRefMut, FnVal, Memory, MemoryKind};
 pub use self::operand::{ImmTy, Immediate, OpTy, Readable};
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs
index 6716888290d..255dd1eba97 100644
--- a/compiler/rustc_const_eval/src/interpret/operand.rs
+++ b/compiler/rustc_const_eval/src/interpret/operand.rs
@@ -169,6 +169,16 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
         ImmTy { imm: val.into(), layout }
     }
 
+    #[inline]
+    pub fn from_scalar_pair(a: Scalar<Prov>, b: Scalar<Prov>, layout: TyAndLayout<'tcx>) -> Self {
+        debug_assert!(
+            matches!(layout.abi, Abi::ScalarPair(..)),
+            "`ImmTy::from_scalar_pair` on non-scalar-pair layout"
+        );
+        let imm = Immediate::ScalarPair(a, b);
+        ImmTy { imm, layout }
+    }
+
     #[inline(always)]
     pub fn from_immediate(imm: Immediate<Prov>, layout: TyAndLayout<'tcx>) -> Self {
         debug_assert!(
diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs
index 79cbda545f1..8c34d05042b 100644
--- a/compiler/rustc_const_eval/src/interpret/step.rs
+++ b/compiler/rustc_const_eval/src/interpret/step.rs
@@ -297,7 +297,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             Discriminant(place) => {
                 let op = self.eval_place_to_op(place, None)?;
                 let variant = self.read_discriminant(&op)?;
-                let discr = self.discriminant_for_variant(op.layout, variant)?;
+                let discr = self.discriminant_for_variant(op.layout.ty, variant)?;
                 self.write_immediate(*discr, &dest)?;
             }
         }
diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs
index 695de54eefa..72100863bb5 100644
--- a/compiler/rustc_feature/src/unstable.rs
+++ b/compiler/rustc_feature/src/unstable.rs
@@ -456,6 +456,8 @@ declare_features! (
     (unstable, ffi_returns_twice, "1.34.0", Some(58314), None),
     /// Allows using `#[repr(align(...))]` on function items
     (unstable, fn_align, "1.53.0", Some(82232), None),
+    /// Allows defining gen blocks and `gen fn`.
+    (unstable, gen_blocks, "CURRENT_RUSTC_VERSION", Some(117078), None),
     /// Infer generic args for both consts and types.
     (unstable, generic_arg_infer, "1.55.0", Some(85077), None),
     /// An extension to the `generic_associated_types` feature, allowing incomplete features.
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index 17c6352ce24..d88f165b9e5 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -1522,6 +1522,9 @@ pub enum CoroutineKind {
     /// An explicit `async` block or the body of an async function.
     Async(CoroutineSource),
 
+    /// An explicit `gen` block or the body of a `gen` function.
+    Gen(CoroutineSource),
+
     /// A coroutine literal created via a `yield` inside a closure.
     Coroutine,
 }
@@ -1538,6 +1541,14 @@ impl fmt::Display for CoroutineKind {
                 k.fmt(f)
             }
             CoroutineKind::Coroutine => f.write_str("coroutine"),
+            CoroutineKind::Gen(k) => {
+                if f.alternate() {
+                    f.write_str("`gen` ")?;
+                } else {
+                    f.write_str("gen ")?
+                }
+                k.fmt(f)
+            }
         }
     }
 }
@@ -2251,6 +2262,7 @@ impl From<CoroutineKind> for YieldSource {
             // Guess based on the kind of the current coroutine.
             CoroutineKind::Coroutine => Self::Yield,
             CoroutineKind::Async(_) => Self::Await { expr: None },
+            CoroutineKind::Gen(_) => Self::Yield,
         }
     }
 }
diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs
index e7060dac844..14cd3881a06 100644
--- a/compiler/rustc_hir_typeck/src/check.rs
+++ b/compiler/rustc_hir_typeck/src/check.rs
@@ -58,15 +58,16 @@ pub(super) fn check_fn<'a, 'tcx>(
     if let Some(kind) = body.coroutine_kind
         && can_be_coroutine.is_some()
     {
-        let yield_ty = if kind == hir::CoroutineKind::Coroutine {
-            let yield_ty = fcx.next_ty_var(TypeVariableOrigin {
-                kind: TypeVariableOriginKind::TypeInference,
-                span,
-            });
-            fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType);
-            yield_ty
-        } else {
-            Ty::new_unit(tcx)
+        let yield_ty = match kind {
+            hir::CoroutineKind::Gen(..) | hir::CoroutineKind::Coroutine => {
+                let yield_ty = fcx.next_ty_var(TypeVariableOrigin {
+                    kind: TypeVariableOriginKind::TypeInference,
+                    span,
+                });
+                fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType);
+                yield_ty
+            }
+            hir::CoroutineKind::Async(..) => Ty::new_unit(tcx),
         };
 
         // Resume type defaults to `()` if the coroutine has no argument.
diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs
index 47bde21ceb2..b102ddd8d86 100644
--- a/compiler/rustc_hir_typeck/src/closure.rs
+++ b/compiler/rustc_hir_typeck/src/closure.rs
@@ -652,6 +652,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                         },
                     )
                 }
+                Some(hir::CoroutineKind::Gen(hir::CoroutineSource::Fn)) => {
+                    todo!("gen closures do not exist yet")
+                }
 
                 _ => astconv.ty_infer(None, decl.output.span()),
             },
diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs
index e1a14ed0faf..7a5dec22fe0 100644
--- a/compiler/rustc_infer/src/infer/opaque_types.rs
+++ b/compiler/rustc_infer/src/infer/opaque_types.rs
@@ -362,6 +362,8 @@ impl<'tcx> InferCtxt<'tcx> {
                 .collect(),
         );
 
+        // FIXME(#42940): This should use the `FreeRegionsVisitor`, but that's
+        // not currently sound until we have existential regions.
         concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
             tcx: self.tcx,
             op: |r| self.member_constraint(opaque_type_key, span, concrete_ty, r, &choice_regions),
diff --git a/compiler/rustc_infer/src/infer/outlives/for_liveness.rs b/compiler/rustc_infer/src/infer/outlives/for_liveness.rs
new file mode 100644
index 00000000000..ebc51b98be5
--- /dev/null
+++ b/compiler/rustc_infer/src/infer/outlives/for_liveness.rs
@@ -0,0 +1,121 @@
+use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
+
+use std::ops::ControlFlow;
+
+use crate::infer::outlives::test_type_match;
+use crate::infer::region_constraints::VerifyIfEq;
+
+/// Visits free regions in the type that are relevant for liveness computation.
+/// These regions are passed to `OP`.
+///
+/// Specifically, we visit all of the regions of types recursively, except if
+/// the type is an alias, we look at the outlives bounds in the param-env
+/// and alias's item bounds. If there is a unique outlives bound, then visit
+/// that instead. If there is not a unique but there is a `'static` outlives
+/// bound, then don't visit anything. Otherwise, walk through the opaque's
+/// regions structurally.
+pub struct FreeRegionsVisitor<'tcx, OP: FnMut(ty::Region<'tcx>)> {
+    pub tcx: TyCtxt<'tcx>,
+    pub param_env: ty::ParamEnv<'tcx>,
+    pub op: OP,
+}
+
+impl<'tcx, OP> TypeVisitor<TyCtxt<'tcx>> for FreeRegionsVisitor<'tcx, OP>
+where
+    OP: FnMut(ty::Region<'tcx>),
+{
+    fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(
+        &mut self,
+        t: &ty::Binder<'tcx, T>,
+    ) -> ControlFlow<Self::BreakTy> {
+        t.super_visit_with(self);
+        ControlFlow::Continue(())
+    }
+
+    fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
+        match *r {
+            // ignore bound regions, keep visiting
+            ty::ReLateBound(_, _) => ControlFlow::Continue(()),
+            _ => {
+                (self.op)(r);
+                ControlFlow::Continue(())
+            }
+        }
+    }
+
+    fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
+        // We're only interested in types involving regions
+        if !ty.flags().intersects(ty::TypeFlags::HAS_FREE_REGIONS) {
+            return ControlFlow::Continue(());
+        }
+
+        match ty.kind() {
+            // We can prove that an alias is live two ways:
+            // 1. All the components are live.
+            //
+            // 2. There is a known outlives bound or where-clause, and that
+            //    region is live.
+            //
+            // We search through the item bounds and where clauses for
+            // either `'static` or a unique outlives region, and if one is
+            // found, we just need to prove that that region is still live.
+            // If one is not found, then we continue to walk through the alias.
+            ty::Alias(kind, ty::AliasTy { def_id, args, .. }) => {
+                let tcx = self.tcx;
+                let param_env = self.param_env;
+                let outlives_bounds: Vec<_> = tcx
+                    .item_bounds(def_id)
+                    .iter_instantiated(tcx, args)
+                    .chain(param_env.caller_bounds())
+                    .filter_map(|clause| {
+                        let outlives = clause.as_type_outlives_clause()?;
+                        if let Some(outlives) = outlives.no_bound_vars()
+                            && outlives.0 == ty
+                        {
+                            Some(outlives.1)
+                        } else {
+                            test_type_match::extract_verify_if_eq(
+                                tcx,
+                                param_env,
+                                &outlives.map_bound(|ty::OutlivesPredicate(ty, bound)| {
+                                    VerifyIfEq { ty, bound }
+                                }),
+                                ty,
+                            )
+                        }
+                    })
+                    .collect();
+                // If we find `'static`, then we know the alias doesn't capture *any* regions.
+                // Otherwise, all of the outlives regions should be equal -- if they're not,
+                // we don't really know how to proceed, so we continue recursing through the
+                // alias.
+                if outlives_bounds.contains(&tcx.lifetimes.re_static) {
+                    // no
+                } else if let Some(r) = outlives_bounds.first()
+                    && outlives_bounds[1..].iter().all(|other_r| other_r == r)
+                {
+                    assert!(r.type_flags().intersects(ty::TypeFlags::HAS_FREE_REGIONS));
+                    r.visit_with(self)?;
+                } else {
+                    // Skip lifetime parameters that are not captures.
+                    let variances = match kind {
+                        ty::Opaque => Some(self.tcx.variances_of(*def_id)),
+                        _ => None,
+                    };
+
+                    for (idx, s) in args.iter().enumerate() {
+                        if variances.map(|variances| variances[idx]) != Some(ty::Variance::Bivariant) {
+                            s.visit_with(self)?;
+                        }
+                    }
+                }
+            }
+
+            _ => {
+                ty.super_visit_with(self)?;
+            }
+        }
+
+        ControlFlow::Continue(())
+    }
+}
diff --git a/compiler/rustc_infer/src/infer/outlives/mod.rs b/compiler/rustc_infer/src/infer/outlives/mod.rs
index cb92fc6ddb6..0987915f4fd 100644
--- a/compiler/rustc_infer/src/infer/outlives/mod.rs
+++ b/compiler/rustc_infer/src/infer/outlives/mod.rs
@@ -9,6 +9,7 @@ use rustc_middle::ty;
 
 pub mod components;
 pub mod env;
+pub mod for_liveness;
 pub mod obligations;
 pub mod test_type_match;
 pub mod verify;
diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
index f606fa483ca..fe13162cd4a 100644
--- a/compiler/rustc_llvm/build.rs
+++ b/compiler/rustc_llvm/build.rs
@@ -258,6 +258,12 @@ fn main() {
     {
         println!("cargo:rustc-link-lib=z");
     } else if target.contains("netbsd") {
+        // On NetBSD/i386, gcc and g++ is built for i486 (to maximize backward compat)
+        // However, LLVM insists on using 64-bit atomics.
+        // This gives rise to a need to link rust itself with -latomic for these targets
+        if target.starts_with("i586") || target.starts_with("i686") {
+            println!("cargo:rustc-link-lib=atomic");
+        }
         println!("cargo:rustc-link-lib=z");
         println!("cargo:rustc-link-lib=execinfo");
     }
diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs
index 4e429f316e8..3cb2e349ce0 100644
--- a/compiler/rustc_middle/src/mir/consts.rs
+++ b/compiler/rustc_middle/src/mir/consts.rs
@@ -172,6 +172,24 @@ impl<'tcx> ConstValue<'tcx> {
         let end = end.try_into().unwrap();
         Some(data.inner().inspect_with_uninit_and_ptr_outside_interpreter(start..end))
     }
+
+    /// Check if a constant may contain provenance information. This is used by MIR opts.
+    /// Can return `true` even if there is no provenance.
+    pub fn may_have_provenance(&self, tcx: TyCtxt<'tcx>, size: Size) -> bool {
+        match *self {
+            ConstValue::ZeroSized | ConstValue::Scalar(Scalar::Int(_)) => return false,
+            ConstValue::Scalar(Scalar::Ptr(..)) => return true,
+            // It's hard to find out the part of the allocation we point to;
+            // just conservatively check everything.
+            ConstValue::Slice { data, meta: _ } => !data.inner().provenance().ptrs().is_empty(),
+            ConstValue::Indirect { alloc_id, offset } => !tcx
+                .global_alloc(alloc_id)
+                .unwrap_memory()
+                .inner()
+                .provenance()
+                .range_empty(super::AllocRange::from(offset..offset + size), &tcx),
+        }
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -485,6 +503,38 @@ impl<'tcx> Const<'tcx> {
             _ => Self::Ty(c),
         }
     }
+
+    /// Return true if any evaluation of this constant always returns the same value,
+    /// taking into account even pointer identity tests.
+    pub fn is_deterministic(&self) -> bool {
+        // Some constants may generate fresh allocations for pointers they contain,
+        // so using the same constant twice can yield two different results:
+        // - valtrees purposefully generate new allocations
+        // - ConstValue::Slice also generate new allocations
+        match self {
+            Const::Ty(c) => match c.kind() {
+                ty::ConstKind::Param(..) => true,
+                // A valtree may be a reference. Valtree references correspond to a
+                // different allocation each time they are evaluated. Valtrees for primitive
+                // types are fine though.
+                ty::ConstKind::Value(_) => c.ty().is_primitive(),
+                ty::ConstKind::Unevaluated(..) | ty::ConstKind::Expr(..) => false,
+                // Should not appear in runtime MIR.
+                ty::ConstKind::Infer(..)
+                | ty::ConstKind::Bound(..)
+                | ty::ConstKind::Placeholder(..)
+                | ty::ConstKind::Error(..) => bug!(),
+            },
+            Const::Unevaluated(..) => false,
+            // If the same slice appears twice in the MIR, we cannot guarantee that we will
+            // give the same `AllocId` to the data.
+            Const::Val(ConstValue::Slice { .. }, _) => false,
+            Const::Val(
+                ConstValue::ZeroSized | ConstValue::Scalar(_) | ConstValue::Indirect { .. },
+                _,
+            ) => true,
+        }
+    }
 }
 
 /// An unevaluated (potentially generic) constant used in MIR.
diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs
index affa83fa348..c2aa015f4b7 100644
--- a/compiler/rustc_middle/src/mir/terminator.rs
+++ b/compiler/rustc_middle/src/mir/terminator.rs
@@ -148,8 +148,15 @@ impl<O> AssertKind<O> {
             RemainderByZero(_) => "attempt to calculate the remainder with a divisor of zero",
             ResumedAfterReturn(CoroutineKind::Coroutine) => "coroutine resumed after completion",
             ResumedAfterReturn(CoroutineKind::Async(_)) => "`async fn` resumed after completion",
+            ResumedAfterReturn(CoroutineKind::Gen(_)) => {
+                "`gen fn` should just keep returning `None` after completion"
+            }
             ResumedAfterPanic(CoroutineKind::Coroutine) => "coroutine resumed after panicking",
             ResumedAfterPanic(CoroutineKind::Async(_)) => "`async fn` resumed after panicking",
+            ResumedAfterPanic(CoroutineKind::Gen(_)) => {
+                "`gen fn` should just keep returning `None` after panicking"
+            }
+
             BoundsCheck { .. } | MisalignedPointerDereference { .. } => {
                 bug!("Unexpected AssertKind")
             }
@@ -236,10 +243,15 @@ impl<O> AssertKind<O> {
             DivisionByZero(_) => middle_assert_divide_by_zero,
             RemainderByZero(_) => middle_assert_remainder_by_zero,
             ResumedAfterReturn(CoroutineKind::Async(_)) => middle_assert_async_resume_after_return,
+            ResumedAfterReturn(CoroutineKind::Gen(_)) => {
+                bug!("gen blocks can be resumed after they return and will keep returning `None`")
+            }
             ResumedAfterReturn(CoroutineKind::Coroutine) => {
                 middle_assert_coroutine_resume_after_return
             }
             ResumedAfterPanic(CoroutineKind::Async(_)) => middle_assert_async_resume_after_panic,
+            // FIXME(gen_blocks): custom error message for `gen` blocks
+            ResumedAfterPanic(CoroutineKind::Gen(_)) => middle_assert_async_resume_after_panic,
             ResumedAfterPanic(CoroutineKind::Coroutine) => {
                 middle_assert_coroutine_resume_after_panic
             }
diff --git a/compiler/rustc_middle/src/traits/select.rs b/compiler/rustc_middle/src/traits/select.rs
index bc6856bc900..f33421bbaa6 100644
--- a/compiler/rustc_middle/src/traits/select.rs
+++ b/compiler/rustc_middle/src/traits/select.rs
@@ -144,6 +144,10 @@ pub enum SelectionCandidate<'tcx> {
     /// generated for an async construct.
     FutureCandidate,
 
+    /// Implementation of an `Iterator` trait by one of the generator types
+    /// generated for a gen construct.
+    IteratorCandidate,
+
     /// Implementation of a `Fn`-family trait by one of the anonymous
     /// types generated for a fn pointer type (e.g., `fn(int) -> int`)
     FnPointerCandidate {
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index a669ff8d961..0b3b6700cec 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -782,6 +782,17 @@ impl<'tcx> TyCtxt<'tcx> {
         matches!(self.coroutine_kind(def_id), Some(hir::CoroutineKind::Async(_)))
     }
 
+    /// Returns `true` if the node pointed to by `def_id` is a general coroutine that implements `Coroutine`.
+    /// This means it is neither an `async` or `gen` construct.
+    pub fn is_general_coroutine(self, def_id: DefId) -> bool {
+        matches!(self.coroutine_kind(def_id), Some(hir::CoroutineKind::Coroutine))
+    }
+
+    /// Returns `true` if the node pointed to by `def_id` is a coroutine for a gen construct.
+    pub fn coroutine_is_gen(self, def_id: DefId) -> bool {
+        matches!(self.coroutine_kind(def_id), Some(hir::CoroutineKind::Gen(_)))
+    }
+
     pub fn stability(self) -> &'tcx stability::Index {
         self.stability_index(())
     }
diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs
index 80af8a92553..6bbc8f70f51 100644
--- a/compiler/rustc_middle/src/ty/print/mod.rs
+++ b/compiler/rustc_middle/src/ty/print/mod.rs
@@ -12,8 +12,6 @@ pub use self::pretty::*;
 
 pub type PrintError = std::fmt::Error;
 
-// FIXME(eddyb) false positive, the lifetime parameters are used with `P:  Printer<...>`.
-#[allow(unused_lifetimes)]
 pub trait Print<'tcx, P> {
     fn print(&self, cx: &mut P) -> Result<(), PrintError>;
 }
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index 433ac33f1b8..799ba2c35ec 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -53,7 +53,6 @@ macro_rules! p {
 }
 macro_rules! define_scoped_cx {
     ($cx:ident) => {
-        #[allow(unused_macros)]
         macro_rules! scoped_cx {
             () => {
                 $cx
@@ -408,8 +407,6 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
         def_id: DefId,
         callers: &mut Vec<DefId>,
     ) -> Result<bool, PrintError> {
-        define_scoped_cx!(self);
-
         debug!("try_print_visible_def_path: def_id={:?}", def_id);
 
         // If `def_id` is a direct or injected extern crate, return the
@@ -1868,8 +1865,6 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
         def_id: DefId,
         args: &'tcx [GenericArg<'tcx>],
     ) -> Result<(), PrintError> {
-        define_scoped_cx!(self);
-
         if args.is_empty() {
             match self.try_print_trimmed_def_path(def_id)? {
                 true => return Ok(()),
@@ -2401,8 +2396,6 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
             let _ = write!(cx, "{cont}");
         };
 
-        define_scoped_cx!(self);
-
         let possible_names = ('a'..='z').rev().map(|s| Symbol::intern(&format!("'{s}")));
 
         let mut available_names = possible_names
@@ -2630,46 +2623,6 @@ where
     }
 }
 
-macro_rules! forward_display_to_print {
-    ($($ty:ty),+) => {
-        // Some of the $ty arguments may not actually use 'tcx
-        $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
-            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-                ty::tls::with(|tcx| {
-                    let mut cx = FmtPrinter::new(tcx, Namespace::TypeNS);
-                    tcx.lift(*self)
-                        .expect("could not lift for printing")
-                        .print(&mut cx)?;
-                    f.write_str(&cx.into_buffer())?;
-                    Ok(())
-                })
-            }
-        })+
-    };
-}
-
-macro_rules! define_print_and_forward_display {
-    (($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
-        define_print!(($self, $cx): $($ty $print)*);
-        forward_display_to_print!($($ty),+);
-    };
-}
-
-macro_rules! define_print {
-    (($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
-        $(impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for $ty {
-            fn print(&$self, $cx: &mut P) -> Result<(), PrintError> {
-                #[allow(unused_mut)]
-                let mut $cx = $cx;
-                define_scoped_cx!($cx);
-                let _: () = $print;
-                #[allow(unreachable_code)]
-                Ok(())
-            }
-        })+
-    };
-}
-
 /// Wrapper type for `ty::TraitRef` which opts-in to pretty printing only
 /// the trait path. That is, it will print `Trait<U>` instead of
 /// `<T as Trait<U>>`.
@@ -2744,6 +2697,43 @@ pub struct PrintClosureAsImpl<'tcx> {
     pub closure: ty::ClosureArgs<'tcx>,
 }
 
+macro_rules! forward_display_to_print {
+    ($($ty:ty),+) => {
+        // Some of the $ty arguments may not actually use 'tcx
+        $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
+            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+                ty::tls::with(|tcx| {
+                    let mut cx = FmtPrinter::new(tcx, Namespace::TypeNS);
+                    tcx.lift(*self)
+                        .expect("could not lift for printing")
+                        .print(&mut cx)?;
+                    f.write_str(&cx.into_buffer())?;
+                    Ok(())
+                })
+            }
+        })+
+    };
+}
+
+macro_rules! define_print {
+    (($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
+        $(impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for $ty {
+            fn print(&$self, $cx: &mut P) -> Result<(), PrintError> {
+                define_scoped_cx!($cx);
+                let _: () = $print;
+                Ok(())
+            }
+        })+
+    };
+}
+
+macro_rules! define_print_and_forward_display {
+    (($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
+        define_print!(($self, $cx): $($ty $print)*);
+        forward_display_to_print!($($ty),+);
+    };
+}
+
 forward_display_to_print! {
     ty::Region<'tcx>,
     Ty<'tcx>,
diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs
index be48c0e8926..d29d1902404 100644
--- a/compiler/rustc_middle/src/ty/util.rs
+++ b/compiler/rustc_middle/src/ty/util.rs
@@ -749,6 +749,7 @@ impl<'tcx> TyCtxt<'tcx> {
             DefKind::Coroutine => match self.coroutine_kind(def_id).unwrap() {
                 rustc_hir::CoroutineKind::Async(..) => "async closure",
                 rustc_hir::CoroutineKind::Coroutine => "coroutine",
+                rustc_hir::CoroutineKind::Gen(..) => "gen closure",
             },
             _ => def_kind.descr(def_id),
         }
@@ -766,6 +767,7 @@ impl<'tcx> TyCtxt<'tcx> {
             DefKind::Coroutine => match self.coroutine_kind(def_id).unwrap() {
                 rustc_hir::CoroutineKind::Async(..) => "an",
                 rustc_hir::CoroutineKind::Coroutine => "a",
+                rustc_hir::CoroutineKind::Gen(..) => "a",
             },
             _ => def_kind.article(),
         }
diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs
index fa56d59dd80..50d244d2831 100644
--- a/compiler/rustc_mir_transform/src/coroutine.rs
+++ b/compiler/rustc_mir_transform/src/coroutine.rs
@@ -224,7 +224,7 @@ struct SuspensionPoint<'tcx> {
 
 struct TransformVisitor<'tcx> {
     tcx: TyCtxt<'tcx>,
-    is_async_kind: bool,
+    coroutine_kind: hir::CoroutineKind,
     state_adt_ref: AdtDef<'tcx>,
     state_args: GenericArgsRef<'tcx>,
 
@@ -249,6 +249,47 @@ struct TransformVisitor<'tcx> {
 }
 
 impl<'tcx> TransformVisitor<'tcx> {
+    fn insert_none_ret_block(&self, body: &mut Body<'tcx>) -> BasicBlock {
+        let block = BasicBlock::new(body.basic_blocks.len());
+
+        let source_info = SourceInfo::outermost(body.span);
+
+        let (kind, idx) = self.coroutine_state_adt_and_variant_idx(true);
+        assert_eq!(self.state_adt_ref.variant(idx).fields.len(), 0);
+        let statements = vec![Statement {
+            kind: StatementKind::Assign(Box::new((
+                Place::return_place(),
+                Rvalue::Aggregate(Box::new(kind), IndexVec::new()),
+            ))),
+            source_info,
+        }];
+
+        body.basic_blocks_mut().push(BasicBlockData {
+            statements,
+            terminator: Some(Terminator { source_info, kind: TerminatorKind::Return }),
+            is_cleanup: false,
+        });
+
+        block
+    }
+
+    fn coroutine_state_adt_and_variant_idx(
+        &self,
+        is_return: bool,
+    ) -> (AggregateKind<'tcx>, VariantIdx) {
+        let idx = VariantIdx::new(match (is_return, self.coroutine_kind) {
+            (true, hir::CoroutineKind::Coroutine) => 1, // CoroutineState::Complete
+            (false, hir::CoroutineKind::Coroutine) => 0, // CoroutineState::Yielded
+            (true, hir::CoroutineKind::Async(_)) => 0,  // Poll::Ready
+            (false, hir::CoroutineKind::Async(_)) => 1, // Poll::Pending
+            (true, hir::CoroutineKind::Gen(_)) => 0,    // Option::None
+            (false, hir::CoroutineKind::Gen(_)) => 1,   // Option::Some
+        });
+
+        let kind = AggregateKind::Adt(self.state_adt_ref.did(), idx, self.state_args, None, None);
+        (kind, idx)
+    }
+
     // Make a `CoroutineState` or `Poll` variant assignment.
     //
     // `core::ops::CoroutineState` only has single element tuple variants,
@@ -261,31 +302,44 @@ impl<'tcx> TransformVisitor<'tcx> {
         is_return: bool,
         statements: &mut Vec<Statement<'tcx>>,
     ) {
-        let idx = VariantIdx::new(match (is_return, self.is_async_kind) {
-            (true, false) => 1,  // CoroutineState::Complete
-            (false, false) => 0, // CoroutineState::Yielded
-            (true, true) => 0,   // Poll::Ready
-            (false, true) => 1,  // Poll::Pending
-        });
+        let (kind, idx) = self.coroutine_state_adt_and_variant_idx(is_return);
 
-        let kind = AggregateKind::Adt(self.state_adt_ref.did(), idx, self.state_args, None, None);
+        match self.coroutine_kind {
+            // `Poll::Pending`
+            CoroutineKind::Async(_) => {
+                if !is_return {
+                    assert_eq!(self.state_adt_ref.variant(idx).fields.len(), 0);
 
-        // `Poll::Pending`
-        if self.is_async_kind && idx == VariantIdx::new(1) {
-            assert_eq!(self.state_adt_ref.variant(idx).fields.len(), 0);
+                    // FIXME(swatinem): assert that `val` is indeed unit?
+                    statements.push(Statement {
+                        kind: StatementKind::Assign(Box::new((
+                            Place::return_place(),
+                            Rvalue::Aggregate(Box::new(kind), IndexVec::new()),
+                        ))),
+                        source_info,
+                    });
+                    return;
+                }
+            }
+            // `Option::None`
+            CoroutineKind::Gen(_) => {
+                if is_return {
+                    assert_eq!(self.state_adt_ref.variant(idx).fields.len(), 0);
 
-            // FIXME(swatinem): assert that `val` is indeed unit?
-            statements.push(Statement {
-                kind: StatementKind::Assign(Box::new((
-                    Place::return_place(),
-                    Rvalue::Aggregate(Box::new(kind), IndexVec::new()),
-                ))),
-                source_info,
-            });
-            return;
+                    statements.push(Statement {
+                        kind: StatementKind::Assign(Box::new((
+                            Place::return_place(),
+                            Rvalue::Aggregate(Box::new(kind), IndexVec::new()),
+                        ))),
+                        source_info,
+                    });
+                    return;
+                }
+            }
+            CoroutineKind::Coroutine => {}
         }
 
-        // else: `Poll::Ready(x)`, `CoroutineState::Yielded(x)` or `CoroutineState::Complete(x)`
+        // else: `Poll::Ready(x)`, `CoroutineState::Yielded(x)`, `CoroutineState::Complete(x)`, or `Option::Some(x)`
         assert_eq!(self.state_adt_ref.variant(idx).fields.len(), 1);
 
         statements.push(Statement {
@@ -1263,10 +1317,13 @@ fn create_coroutine_resume_function<'tcx>(
     }
 
     if can_return {
-        cases.insert(
-            1,
-            (RETURNED, insert_panic_block(tcx, body, ResumedAfterReturn(coroutine_kind))),
-        );
+        let block = match coroutine_kind {
+            CoroutineKind::Async(_) | CoroutineKind::Coroutine => {
+                insert_panic_block(tcx, body, ResumedAfterReturn(coroutine_kind))
+            }
+            CoroutineKind::Gen(_) => transform.insert_none_ret_block(body),
+        };
+        cases.insert(1, (RETURNED, block));
     }
 
     insert_switch(body, cases, &transform, TerminatorKind::Unreachable);
@@ -1439,18 +1496,28 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
         };
 
         let is_async_kind = matches!(body.coroutine_kind(), Some(CoroutineKind::Async(_)));
-        let (state_adt_ref, state_args) = if is_async_kind {
-            // Compute Poll<return_ty>
-            let poll_did = tcx.require_lang_item(LangItem::Poll, None);
-            let poll_adt_ref = tcx.adt_def(poll_did);
-            let poll_args = tcx.mk_args(&[body.return_ty().into()]);
-            (poll_adt_ref, poll_args)
-        } else {
-            // Compute CoroutineState<yield_ty, return_ty>
-            let state_did = tcx.require_lang_item(LangItem::CoroutineState, None);
-            let state_adt_ref = tcx.adt_def(state_did);
-            let state_args = tcx.mk_args(&[yield_ty.into(), body.return_ty().into()]);
-            (state_adt_ref, state_args)
+        let (state_adt_ref, state_args) = match body.coroutine_kind().unwrap() {
+            CoroutineKind::Async(_) => {
+                // Compute Poll<return_ty>
+                let poll_did = tcx.require_lang_item(LangItem::Poll, None);
+                let poll_adt_ref = tcx.adt_def(poll_did);
+                let poll_args = tcx.mk_args(&[body.return_ty().into()]);
+                (poll_adt_ref, poll_args)
+            }
+            CoroutineKind::Gen(_) => {
+                // Compute Option<yield_ty>
+                let option_did = tcx.require_lang_item(LangItem::Option, None);
+                let option_adt_ref = tcx.adt_def(option_did);
+                let option_args = tcx.mk_args(&[body.yield_ty().unwrap().into()]);
+                (option_adt_ref, option_args)
+            }
+            CoroutineKind::Coroutine => {
+                // Compute CoroutineState<yield_ty, return_ty>
+                let state_did = tcx.require_lang_item(LangItem::CoroutineState, None);
+                let state_adt_ref = tcx.adt_def(state_did);
+                let state_args = tcx.mk_args(&[yield_ty.into(), body.return_ty().into()]);
+                (state_adt_ref, state_args)
+            }
         };
         let ret_ty = Ty::new_adt(tcx, state_adt_ref, state_args);
 
@@ -1518,7 +1585,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
         // or Poll::Ready(x) and Poll::Pending respectively depending on `is_async_kind`.
         let mut transform = TransformVisitor {
             tcx,
-            is_async_kind,
+            coroutine_kind: body.coroutine_kind().unwrap(),
             state_adt_ref,
             state_args,
             remap,
diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs
index 2c29978173f..fd067cb234b 100644
--- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs
+++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs
@@ -406,7 +406,8 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
                 TrackElem::Variant(idx) => self.ecx.project_downcast(op, idx).ok(),
                 TrackElem::Discriminant => {
                     let variant = self.ecx.read_discriminant(op).ok()?;
-                    let discr_value = self.ecx.discriminant_for_variant(op.layout, variant).ok()?;
+                    let discr_value =
+                        self.ecx.discriminant_for_variant(op.layout.ty, variant).ok()?;
                     Some(discr_value.into())
                 }
                 TrackElem::DerefLen => {
@@ -507,7 +508,8 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
             return None;
         }
         let enum_ty_layout = self.tcx.layout_of(self.param_env.and(enum_ty)).ok()?;
-        let discr_value = self.ecx.discriminant_for_variant(enum_ty_layout, variant_index).ok()?;
+        let discr_value =
+            self.ecx.discriminant_for_variant(enum_ty_layout.ty, variant_index).ok()?;
         Some(discr_value.to_scalar())
     }
 
@@ -854,7 +856,7 @@ impl<'tcx> Visitor<'tcx> for OperandCollector<'tcx, '_, '_, '_> {
     }
 }
 
-struct DummyMachine;
+pub(crate) struct DummyMachine;
 
 impl<'mir, 'tcx: 'mir> rustc_const_eval::interpret::Machine<'mir, 'tcx> for DummyMachine {
     rustc_const_eval::interpret::compile_time_machine!(<'mir, 'tcx>);
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs
index eece7c3e834..de0dc25808b 100644
--- a/compiler/rustc_mir_transform/src/gvn.rs
+++ b/compiler/rustc_mir_transform/src/gvn.rs
@@ -52,19 +52,59 @@
 //! _a = *_b // _b is &Freeze
 //! _c = *_b // replaced by _c = _a
 //! ```
+//!
+//! # Determinism of constant propagation
+//!
+//! When registering a new `Value`, we attempt to opportunistically evaluate it as a constant.
+//! The evaluated form is inserted in `evaluated` as an `OpTy` or `None` if evaluation failed.
+//!
+//! The difficulty is non-deterministic evaluation of MIR constants. Some `Const` can have
+//! different runtime values each time they are evaluated. This is the case with
+//! `Const::Slice` which have a new pointer each time they are evaluated, and constants that
+//! contain a fn pointer (`AllocId` pointing to a `GlobalAlloc::Function`) pointing to a different
+//! symbol in each codegen unit.
+//!
+//! Meanwhile, we want to be able to read indirect constants. For instance:
+//! ```
+//! static A: &'static &'static u8 = &&63;
+//! fn foo() -> u8 {
+//!     **A // We want to replace by 63.
+//! }
+//! fn bar() -> u8 {
+//!     b"abc"[1] // We want to replace by 'b'.
+//! }
+//! ```
+//!
+//! The `Value::Constant` variant stores a possibly unevaluated constant. Evaluating that constant
+//! may be non-deterministic. When that happens, we assign a disambiguator to ensure that we do not
+//! merge the constants. See `duplicate_slice` test in `gvn.rs`.
+//!
+//! Second, when writing constants in MIR, we do not write `Const::Slice` or `Const`
+//! that contain `AllocId`s.
 
+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::graph::dominators::Dominators;
+use rustc_hir::def::DefKind;
 use rustc_index::bit_set::BitSet;
 use rustc_index::IndexVec;
 use rustc_macros::newtype_index;
+use rustc_middle::mir::interpret::GlobalAlloc;
 use rustc_middle::mir::visit::*;
 use rustc_middle::mir::*;
-use rustc_middle::ty::{self, Ty, TyCtxt};
-use rustc_target::abi::{VariantIdx, FIRST_VARIANT};
+use rustc_middle::ty::adjustment::PointerCoercion;
+use rustc_middle::ty::layout::LayoutOf;
+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 std::borrow::Cow;
 
+use crate::dataflow_const_prop::DummyMachine;
 use crate::ssa::{AssignedValue, SsaLocals};
 use crate::MirPass;
+use either::Either;
 
 pub struct GVN;
 
@@ -118,22 +158,33 @@ fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         let data = &mut body.basic_blocks.as_mut_preserves_cfg()[bb];
         state.visit_basic_block_data(bb, data);
     }
-    let any_replacement = state.any_replacement;
 
     // For each local that is reused (`y` above), we remove its storage statements do avoid any
     // difficulty. Those locals are SSA, so should be easy to optimize by LLVM without storage
     // statements.
     StorageRemover { tcx, reused_locals: state.reused_locals }.visit_body_preserves_cfg(body);
-
-    if any_replacement {
-        crate::simplify::remove_unused_definitions(body);
-    }
 }
 
 newtype_index! {
     struct VnIndex {}
 }
 
+/// Computing the aggregate's type can be quite slow, so we only keep the minimal amount of
+/// information to reconstruct it when needed.
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
+enum AggregateTy<'tcx> {
+    /// Invariant: this must not be used for an empty array.
+    Array,
+    Tuple,
+    Def(DefId, ty::GenericArgsRef<'tcx>),
+}
+
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
+enum AddressKind {
+    Ref(BorrowKind),
+    Address(Mutability),
+}
+
 #[derive(Debug, PartialEq, Eq, Hash)]
 enum Value<'tcx> {
     // Root values.
@@ -141,15 +192,21 @@ enum Value<'tcx> {
     /// The `usize` is a counter incremented by `new_opaque`.
     Opaque(usize),
     /// Evaluated or unevaluated constant value.
-    Constant(Const<'tcx>),
+    Constant {
+        value: Const<'tcx>,
+        /// Some constants do not have a deterministic value. To avoid merging two instances of the
+        /// same `Const`, we assign them an additional integer index.
+        disambiguator: usize,
+    },
     /// An aggregate value, either tuple/closure/struct/enum.
     /// This does not contain unions, as we cannot reason with the value.
-    Aggregate(Ty<'tcx>, VariantIdx, Vec<VnIndex>),
+    Aggregate(AggregateTy<'tcx>, VariantIdx, Vec<VnIndex>),
     /// This corresponds to a `[value; count]` expression.
     Repeat(VnIndex, ty::Const<'tcx>),
     /// The address of a place.
     Address {
         place: Place<'tcx>,
+        kind: AddressKind,
         /// Give each borrow and pointer a different provenance, so we don't merge them.
         provenance: usize,
     },
@@ -177,6 +234,7 @@ enum Value<'tcx> {
 
 struct VnState<'body, 'tcx> {
     tcx: TyCtxt<'tcx>,
+    ecx: InterpCx<'tcx, 'tcx, DummyMachine>,
     param_env: ty::ParamEnv<'tcx>,
     local_decls: &'body LocalDecls<'tcx>,
     /// Value stored in each local.
@@ -184,13 +242,14 @@ struct VnState<'body, 'tcx> {
     /// First local to be assigned that value.
     rev_locals: FxHashMap<VnIndex, Vec<Local>>,
     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>,
     ssa: &'body SsaLocals,
     dominators: &'body Dominators<BasicBlock>,
     reused_locals: BitSet<Local>,
-    any_replacement: bool,
 }
 
 impl<'body, 'tcx> VnState<'body, 'tcx> {
@@ -203,23 +262,30 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
     ) -> Self {
         VnState {
             tcx,
+            ecx: InterpCx::new(tcx, DUMMY_SP, param_env, DummyMachine),
             param_env,
             local_decls,
             locals: IndexVec::from_elem(None, local_decls),
             rev_locals: FxHashMap::default(),
             values: FxIndexSet::default(),
+            evaluated: IndexVec::new(),
             next_opaque: Some(0),
             ssa,
             dominators,
             reused_locals: BitSet::new_empty(local_decls.len()),
-            any_replacement: false,
         }
     }
 
     #[instrument(level = "trace", skip(self), ret)]
     fn insert(&mut self, value: Value<'tcx>) -> VnIndex {
-        let (index, _) = self.values.insert_full(value);
-        VnIndex::from_usize(index)
+        let (index, new) = self.values.insert_full(value);
+        let index = VnIndex::from_usize(index);
+        if new {
+            let evaluated = self.eval_to_const(index);
+            let _index = self.evaluated.push(evaluated);
+            debug_assert_eq!(index, _index);
+        }
+        index
     }
 
     /// Create a new `Value` for which we have no information at all, except that it is distinct
@@ -234,9 +300,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
 
     /// Create a new `Value::Address` distinct from all the others.
     #[instrument(level = "trace", skip(self), ret)]
-    fn new_pointer(&mut self, place: Place<'tcx>) -> Option<VnIndex> {
+    fn new_pointer(&mut self, place: Place<'tcx>, kind: AddressKind) -> Option<VnIndex> {
         let next_opaque = self.next_opaque.as_mut()?;
-        let value = Value::Address { place, provenance: *next_opaque };
+        let value = Value::Address { place, kind, provenance: *next_opaque };
         *next_opaque += 1;
         Some(self.insert(value))
     }
@@ -258,6 +324,343 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
         }
     }
 
+    fn insert_constant(&mut self, value: Const<'tcx>) -> Option<VnIndex> {
+        let disambiguator = if value.is_deterministic() {
+            // The constant is deterministic, no need to disambiguate.
+            0
+        } else {
+            // Multiple mentions of this constant will yield different values,
+            // so assign a different `disambiguator` to ensure they do not get the same `VnIndex`.
+            let next_opaque = self.next_opaque.as_mut()?;
+            let disambiguator = *next_opaque;
+            *next_opaque += 1;
+            disambiguator
+        };
+        Some(self.insert(Value::Constant { value, disambiguator }))
+    }
+
+    fn insert_scalar(&mut self, scalar: Scalar, ty: Ty<'tcx>) -> VnIndex {
+        self.insert_constant(Const::from_scalar(self.tcx, scalar, ty))
+            .expect("scalars are deterministic")
+    }
+
+    #[instrument(level = "trace", skip(self), ret)]
+    fn eval_to_const(&mut self, value: VnIndex) -> Option<OpTy<'tcx>> {
+        use Value::*;
+        let op = match *self.get(value) {
+            Opaque(_) => return None,
+            // Do not bother evaluating repeat expressions. This would uselessly consume memory.
+            Repeat(..) => return None,
+
+            Constant { ref value, disambiguator: _ } => {
+                self.ecx.eval_mir_constant(value, None, None).ok()?
+            }
+            Aggregate(kind, variant, ref fields) => {
+                let fields = fields
+                    .iter()
+                    .map(|&f| self.evaluated[f].as_ref())
+                    .collect::<Option<Vec<_>>>()?;
+                let ty = match kind {
+                    AggregateTy::Array => {
+                        assert!(fields.len() > 0);
+                        Ty::new_array(self.tcx, fields[0].layout.ty, fields.len() as u64)
+                    }
+                    AggregateTy::Tuple => {
+                        Ty::new_tup_from_iter(self.tcx, fields.iter().map(|f| f.layout.ty))
+                    }
+                    AggregateTy::Def(def_id, args) => {
+                        self.tcx.type_of(def_id).instantiate(self.tcx, args)
+                    }
+                };
+                let variant = if ty.is_enum() { Some(variant) } else { None };
+                let ty = self.ecx.layout_of(ty).ok()?;
+                if ty.is_zst() {
+                    ImmTy::uninit(ty).into()
+                } else if matches!(ty.abi, Abi::Scalar(..) | Abi::ScalarPair(..)) {
+                    let dest = self.ecx.allocate(ty, MemoryKind::Stack).ok()?;
+                    let variant_dest = if let Some(variant) = variant {
+                        self.ecx.project_downcast(&dest, variant).ok()?
+                    } else {
+                        dest.clone()
+                    };
+                    for (field_index, op) in fields.into_iter().enumerate() {
+                        let field_dest = self.ecx.project_field(&variant_dest, field_index).ok()?;
+                        self.ecx.copy_op(op, &field_dest, /*allow_transmute*/ false).ok()?;
+                    }
+                    self.ecx.write_discriminant(variant.unwrap_or(FIRST_VARIANT), &dest).ok()?;
+                    self.ecx.alloc_mark_immutable(dest.ptr().provenance.unwrap()).ok()?;
+                    dest.into()
+                } else {
+                    return None;
+                }
+            }
+
+            Projection(base, elem) => {
+                let value = self.evaluated[base].as_ref()?;
+                let elem = match elem {
+                    ProjectionElem::Deref => ProjectionElem::Deref,
+                    ProjectionElem::Downcast(name, read_variant) => {
+                        ProjectionElem::Downcast(name, read_variant)
+                    }
+                    ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, ty),
+                    ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
+                        ProjectionElem::ConstantIndex { offset, min_length, from_end }
+                    }
+                    ProjectionElem::Subslice { from, to, from_end } => {
+                        ProjectionElem::Subslice { from, to, from_end }
+                    }
+                    ProjectionElem::OpaqueCast(ty) => ProjectionElem::OpaqueCast(ty),
+                    ProjectionElem::Subtype(ty) => ProjectionElem::Subtype(ty),
+                    // This should have been replaced by a `ConstantIndex` earlier.
+                    ProjectionElem::Index(_) => return None,
+                };
+                self.ecx.project(value, elem).ok()?
+            }
+            Address { place, kind, provenance: _ } => {
+                if !place.is_indirect_first_projection() {
+                    return None;
+                }
+                let local = self.locals[place.local]?;
+                let pointer = self.evaluated[local].as_ref()?;
+                let mut mplace = self.ecx.deref_pointer(pointer).ok()?;
+                for proj in place.projection.iter().skip(1) {
+                    // We have no call stack to associate a local with a value, so we cannot interpret indexing.
+                    if matches!(proj, ProjectionElem::Index(_)) {
+                        return None;
+                    }
+                    mplace = self.ecx.project(&mplace, proj).ok()?;
+                }
+                let pointer = mplace.to_ref(&self.ecx);
+                let ty = match kind {
+                    AddressKind::Ref(bk) => Ty::new_ref(
+                        self.tcx,
+                        self.tcx.lifetimes.re_erased,
+                        ty::TypeAndMut { ty: mplace.layout.ty, mutbl: bk.to_mutbl_lossy() },
+                    ),
+                    AddressKind::Address(mutbl) => {
+                        Ty::new_ptr(self.tcx, TypeAndMut { ty: mplace.layout.ty, mutbl })
+                    }
+                };
+                let layout = self.ecx.layout_of(ty).ok()?;
+                ImmTy::from_immediate(pointer, layout).into()
+            }
+
+            Discriminant(base) => {
+                let base = self.evaluated[base].as_ref()?;
+                let variant = self.ecx.read_discriminant(base).ok()?;
+                let discr_value =
+                    self.ecx.discriminant_for_variant(base.layout.ty, variant).ok()?;
+                discr_value.into()
+            }
+            Len(slice) => {
+                let slice = self.evaluated[slice].as_ref()?;
+                let usize_layout = self.ecx.layout_of(self.tcx.types.usize).unwrap();
+                let len = slice.len(&self.ecx).ok()?;
+                let imm = ImmTy::try_from_uint(len, usize_layout)?;
+                imm.into()
+            }
+            NullaryOp(null_op, ty) => {
+                let layout = self.ecx.layout_of(ty).ok()?;
+                if let NullOp::SizeOf | NullOp::AlignOf = null_op && layout.is_unsized() {
+                    return None;
+                }
+                let val = match null_op {
+                    NullOp::SizeOf => layout.size.bytes(),
+                    NullOp::AlignOf => layout.align.abi.bytes(),
+                    NullOp::OffsetOf(fields) => layout
+                        .offset_of_subfield(&self.ecx, fields.iter().map(|f| f.index()))
+                        .bytes(),
+                };
+                let usize_layout = self.ecx.layout_of(self.tcx.types.usize).unwrap();
+                let imm = ImmTy::try_from_uint(val, usize_layout)?;
+                imm.into()
+            }
+            UnaryOp(un_op, operand) => {
+                let operand = self.evaluated[operand].as_ref()?;
+                let operand = self.ecx.read_immediate(operand).ok()?;
+                let (val, _) = self.ecx.overflowing_unary_op(un_op, &operand).ok()?;
+                val.into()
+            }
+            BinaryOp(bin_op, lhs, rhs) => {
+                let lhs = self.evaluated[lhs].as_ref()?;
+                let lhs = self.ecx.read_immediate(lhs).ok()?;
+                let rhs = self.evaluated[rhs].as_ref()?;
+                let rhs = self.ecx.read_immediate(rhs).ok()?;
+                let (val, _) = self.ecx.overflowing_binary_op(bin_op, &lhs, &rhs).ok()?;
+                val.into()
+            }
+            CheckedBinaryOp(bin_op, lhs, rhs) => {
+                let lhs = self.evaluated[lhs].as_ref()?;
+                let lhs = self.ecx.read_immediate(lhs).ok()?;
+                let rhs = self.evaluated[rhs].as_ref()?;
+                let rhs = self.ecx.read_immediate(rhs).ok()?;
+                let (val, overflowed) = self.ecx.overflowing_binary_op(bin_op, &lhs, &rhs).ok()?;
+                let tuple = Ty::new_tup_from_iter(
+                    self.tcx,
+                    [val.layout.ty, self.tcx.types.bool].into_iter(),
+                );
+                let tuple = self.ecx.layout_of(tuple).ok()?;
+                ImmTy::from_scalar_pair(val.to_scalar(), Scalar::from_bool(overflowed), tuple)
+                    .into()
+            }
+            Cast { kind, value, from: _, to } => match kind {
+                CastKind::IntToInt | CastKind::IntToFloat => {
+                    let value = self.evaluated[value].as_ref()?;
+                    let value = self.ecx.read_immediate(value).ok()?;
+                    let to = self.ecx.layout_of(to).ok()?;
+                    let res = self.ecx.int_to_int_or_float(&value, to).ok()?;
+                    res.into()
+                }
+                CastKind::FloatToFloat | CastKind::FloatToInt => {
+                    let value = self.evaluated[value].as_ref()?;
+                    let value = self.ecx.read_immediate(value).ok()?;
+                    let to = self.ecx.layout_of(to).ok()?;
+                    let res = self.ecx.float_to_float_or_int(&value, to).ok()?;
+                    res.into()
+                }
+                CastKind::Transmute => {
+                    let value = self.evaluated[value].as_ref()?;
+                    let to = self.ecx.layout_of(to).ok()?;
+                    // `offset` for immediates only supports scalar/scalar-pair ABIs,
+                    // so bail out if the target is not one.
+                    if value.as_mplace_or_imm().is_right() {
+                        match (value.layout.abi, to.abi) {
+                            (Abi::Scalar(..), Abi::Scalar(..)) => {}
+                            (Abi::ScalarPair(..), Abi::ScalarPair(..)) => {}
+                            _ => return None,
+                        }
+                    }
+                    value.offset(Size::ZERO, to, &self.ecx).ok()?
+                }
+                _ => return None,
+            },
+        };
+        Some(op)
+    }
+
+    fn project(
+        &mut self,
+        place: PlaceRef<'tcx>,
+        value: VnIndex,
+        proj: PlaceElem<'tcx>,
+    ) -> Option<VnIndex> {
+        let proj = match proj {
+            ProjectionElem::Deref => {
+                let ty = place.ty(self.local_decls, self.tcx).ty;
+                if let Some(Mutability::Not) = ty.ref_mutability()
+                    && let Some(pointee_ty) = ty.builtin_deref(true)
+                    && pointee_ty.ty.is_freeze(self.tcx, self.param_env)
+                {
+                    // An immutable borrow `_x` always points to the same value for the
+                    // lifetime of the borrow, so we can merge all instances of `*_x`.
+                    ProjectionElem::Deref
+                } else {
+                    return None;
+                }
+            }
+            ProjectionElem::Downcast(name, index) => ProjectionElem::Downcast(name, index),
+            ProjectionElem::Field(f, ty) => {
+                if let Value::Aggregate(_, _, fields) = self.get(value) {
+                    return Some(fields[f.as_usize()]);
+                } else if let Value::Projection(outer_value, ProjectionElem::Downcast(_, read_variant)) = self.get(value)
+                    && let Value::Aggregate(_, written_variant, fields) = self.get(*outer_value)
+                    // This pass is not aware of control-flow, so we do not know whether the
+                    // replacement we are doing is actually reachable. We could be in any arm of
+                    // ```
+                    // match Some(x) {
+                    //     Some(y) => /* stuff */,
+                    //     None => /* other */,
+                    // }
+                    // ```
+                    //
+                    // In surface rust, the current statement would be unreachable.
+                    //
+                    // However, from the reference chapter on enums and RFC 2195,
+                    // accessing the wrong variant is not UB if the enum has repr.
+                    // So it's not impossible for a series of MIR opts to generate
+                    // a downcast to an inactive variant.
+                    && written_variant == read_variant
+                {
+                    return Some(fields[f.as_usize()]);
+                }
+                ProjectionElem::Field(f, ty)
+            }
+            ProjectionElem::Index(idx) => {
+                if let Value::Repeat(inner, _) = self.get(value) {
+                    return Some(*inner);
+                }
+                let idx = self.locals[idx]?;
+                ProjectionElem::Index(idx)
+            }
+            ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
+                match self.get(value) {
+                    Value::Repeat(inner, _) => {
+                        return Some(*inner);
+                    }
+                    Value::Aggregate(AggregateTy::Array, _, operands) => {
+                        let offset = if from_end {
+                            operands.len() - offset as usize
+                        } else {
+                            offset as usize
+                        };
+                        return operands.get(offset).copied();
+                    }
+                    _ => {}
+                };
+                ProjectionElem::ConstantIndex { offset, min_length, from_end }
+            }
+            ProjectionElem::Subslice { from, to, from_end } => {
+                ProjectionElem::Subslice { from, to, from_end }
+            }
+            ProjectionElem::OpaqueCast(ty) => ProjectionElem::OpaqueCast(ty),
+            ProjectionElem::Subtype(ty) => ProjectionElem::Subtype(ty),
+        };
+
+        Some(self.insert(Value::Projection(value, proj)))
+    }
+
+    /// Simplify the projection chain if we know better.
+    #[instrument(level = "trace", skip(self))]
+    fn simplify_place_projection(&mut self, place: &mut Place<'tcx>, location: Location) {
+        // If the projection is indirect, we treat the local as a value, so can replace it with
+        // another local.
+        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;
+            self.reused_locals.insert(new_local);
+        }
+
+        let mut projection = Cow::Borrowed(&place.projection[..]);
+
+        for i in 0..projection.len() {
+            let elem = projection[i];
+            if let ProjectionElem::Index(idx) = elem
+                && let Some(idx) = self.locals[idx]
+            {
+                if let Some(offset) = self.evaluated[idx].as_ref()
+                    && let Ok(offset) = self.ecx.read_target_usize(offset)
+                {
+                    projection.to_mut()[i] = ProjectionElem::ConstantIndex {
+                        offset,
+                        min_length: offset + 1,
+                        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);
+                }
+            }
+        }
+
+        if projection.is_owned() {
+            place.projection = self.tcx.mk_place_elems(&projection);
+        }
+
+        trace!(?place);
+    }
+
     /// Represent the *value* which would be read from `place`, and point `place` to a preexisting
     /// place with the same value (if that already exists).
     #[instrument(level = "trace", skip(self), ret)]
@@ -266,6 +669,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
         place: &mut Place<'tcx>,
         location: Location,
     ) -> Option<VnIndex> {
+        self.simplify_place_projection(place, location);
+
         // Invariant: `place` and `place_ref` point to the same value, even if they point to
         // different memory locations.
         let mut place_ref = place.as_ref();
@@ -280,58 +685,18 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
                 place_ref = PlaceRef { local, projection: &place.projection[index..] };
             }
 
-            let proj = match proj {
-                ProjectionElem::Deref => {
-                    let ty = Place::ty_from(
-                        place.local,
-                        &place.projection[..index],
-                        self.local_decls,
-                        self.tcx,
-                    )
-                    .ty;
-                    if let Some(Mutability::Not) = ty.ref_mutability()
-                        && let Some(pointee_ty) = ty.builtin_deref(true)
-                        && pointee_ty.ty.is_freeze(self.tcx, self.param_env)
-                    {
-                        // An immutable borrow `_x` always points to the same value for the
-                        // lifetime of the borrow, so we can merge all instances of `*_x`.
-                        ProjectionElem::Deref
-                    } else {
-                        return None;
-                    }
-                }
-                ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, ty),
-                ProjectionElem::Index(idx) => {
-                    let idx = self.locals[idx]?;
-                    ProjectionElem::Index(idx)
-                }
-                ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
-                    ProjectionElem::ConstantIndex { offset, min_length, from_end }
-                }
-                ProjectionElem::Subslice { from, to, from_end } => {
-                    ProjectionElem::Subslice { from, to, from_end }
-                }
-                ProjectionElem::Downcast(name, index) => ProjectionElem::Downcast(name, index),
-                ProjectionElem::OpaqueCast(ty) => ProjectionElem::OpaqueCast(ty),
-                ProjectionElem::Subtype(ty) => ProjectionElem::Subtype(ty),
-            };
-            value = self.insert(Value::Projection(value, proj));
+            let base = PlaceRef { local: place.local, projection: &place.projection[..index] };
+            value = self.project(base, value, proj)?;
         }
 
-        if let Some(local) = self.try_as_local(value, location)
-            && local != place.local
-        // in case we had no projection to begin with.
-        {
-            *place = local.into();
-            self.reused_locals.insert(local);
-            self.any_replacement = true;
-        } else if place_ref.local != place.local
-            || place_ref.projection.len() < place.projection.len()
-        {
+        if let Some(new_local) = self.try_as_local(value, location) {
+            place_ref = PlaceRef { local: new_local, projection: &[] };
+        }
+
+        if place_ref.local != place.local || place_ref.projection.len() < place.projection.len() {
             // By the invariant on `place_ref`.
             *place = place_ref.project_deeper(&[], self.tcx);
             self.reused_locals.insert(place_ref.local);
-            self.any_replacement = true;
         }
 
         Some(value)
@@ -344,12 +709,14 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
         location: Location,
     ) -> Option<VnIndex> {
         match *operand {
-            Operand::Constant(ref constant) => Some(self.insert(Value::Constant(constant.const_))),
+            Operand::Constant(ref mut constant) => {
+                let const_ = constant.const_.normalize(self.tcx, self.param_env);
+                self.insert_constant(const_)
+            }
             Operand::Copy(ref mut place) | Operand::Move(ref mut place) => {
                 let value = self.simplify_place_value(place, location)?;
                 if let Some(const_) = self.try_as_constant(value) {
                     *operand = Operand::Constant(Box::new(const_));
-                    self.any_replacement = true;
                 }
                 Some(value)
             }
@@ -378,24 +745,15 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
                 Value::Repeat(op, amount)
             }
             Rvalue::NullaryOp(op, ty) => Value::NullaryOp(op, ty),
-            Rvalue::Aggregate(box ref kind, ref mut fields) => {
-                let variant_index = match *kind {
-                    AggregateKind::Array(..)
-                    | AggregateKind::Tuple
-                    | AggregateKind::Closure(..)
-                    | AggregateKind::Coroutine(..) => FIRST_VARIANT,
-                    AggregateKind::Adt(_, variant_index, _, _, None) => variant_index,
-                    // Do not track unions.
-                    AggregateKind::Adt(_, _, _, _, Some(_)) => return None,
-                };
-                let fields: Option<Vec<_>> = fields
-                    .iter_mut()
-                    .map(|op| self.simplify_operand(op, location).or_else(|| self.new_opaque()))
-                    .collect();
-                let ty = rvalue.ty(self.local_decls, self.tcx);
-                Value::Aggregate(ty, variant_index, fields?)
+            Rvalue::Aggregate(..) => return self.simplify_aggregate(rvalue, location),
+            Rvalue::Ref(_, borrow_kind, ref mut place) => {
+                self.simplify_place_projection(place, location);
+                return self.new_pointer(*place, AddressKind::Ref(borrow_kind));
+            }
+            Rvalue::AddressOf(mutbl, ref mut place) => {
+                self.simplify_place_projection(place, location);
+                return self.new_pointer(*place, AddressKind::Address(mutbl));
             }
-            Rvalue::Ref(.., place) | Rvalue::AddressOf(_, place) => return self.new_pointer(place),
 
             // Operations.
             Rvalue::Len(ref mut place) => {
@@ -405,6 +763,14 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
             Rvalue::Cast(kind, ref mut value, to) => {
                 let from = value.ty(self.local_decls, self.tcx);
                 let value = self.simplify_operand(value, location)?;
+                if let CastKind::PointerCoercion(
+                    PointerCoercion::ReifyFnPointer | PointerCoercion::ClosureFnPointer(_),
+                ) = kind
+                {
+                    // Each reification of a generic fn may get a different pointer.
+                    // Do not try to merge them.
+                    return self.new_opaque();
+                }
                 Value::Cast { kind, value, from, to }
             }
             Rvalue::BinaryOp(op, box (ref mut lhs, ref mut rhs)) => {
@@ -423,6 +789,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
             }
             Rvalue::Discriminant(ref mut place) => {
                 let place = self.simplify_place_value(place, location)?;
+                if let Some(discr) = self.simplify_discriminant(place) {
+                    return Some(discr);
+                }
                 Value::Discriminant(place)
             }
 
@@ -432,45 +801,182 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
         debug!(?value);
         Some(self.insert(value))
     }
+
+    fn simplify_discriminant(&mut self, place: VnIndex) -> Option<VnIndex> {
+        if let Value::Aggregate(enum_ty, variant, _) = *self.get(place)
+            && let AggregateTy::Def(enum_did, enum_substs) = enum_ty
+            && let DefKind::Enum = self.tcx.def_kind(enum_did)
+        {
+            let enum_ty = self.tcx.type_of(enum_did).instantiate(self.tcx, enum_substs);
+            let discr = self.ecx.discriminant_for_variant(enum_ty, variant).ok()?;
+            return Some(self.insert_scalar(discr.to_scalar(), discr.layout.ty));
+        }
+
+        None
+    }
+
+    fn simplify_aggregate(
+        &mut self,
+        rvalue: &mut Rvalue<'tcx>,
+        location: Location,
+    ) -> Option<VnIndex> {
+        let Rvalue::Aggregate(box ref kind, ref mut fields) = *rvalue else { bug!() };
+
+        let tcx = self.tcx;
+        if fields.is_empty() {
+            let is_zst = match *kind {
+                AggregateKind::Array(..) | AggregateKind::Tuple | AggregateKind::Closure(..) => {
+                    true
+                }
+                // Only enums can be non-ZST.
+                AggregateKind::Adt(did, ..) => tcx.def_kind(did) != DefKind::Enum,
+                // Coroutines are never ZST, as they at least contain the implicit states.
+                AggregateKind::Coroutine(..) => false,
+            };
+
+            if is_zst {
+                let ty = rvalue.ty(self.local_decls, tcx);
+                return self.insert_constant(Const::zero_sized(ty));
+            }
+        }
+
+        let (ty, variant_index) = match *kind {
+            AggregateKind::Array(..) => {
+                assert!(!fields.is_empty());
+                (AggregateTy::Array, FIRST_VARIANT)
+            }
+            AggregateKind::Tuple => {
+                assert!(!fields.is_empty());
+                (AggregateTy::Tuple, FIRST_VARIANT)
+            }
+            AggregateKind::Closure(did, substs) | AggregateKind::Coroutine(did, substs, _) => {
+                (AggregateTy::Def(did, substs), FIRST_VARIANT)
+            }
+            AggregateKind::Adt(did, variant_index, substs, _, None) => {
+                (AggregateTy::Def(did, substs), variant_index)
+            }
+            // Do not track unions.
+            AggregateKind::Adt(_, _, _, _, Some(_)) => return None,
+        };
+
+        let fields: Option<Vec<_>> = fields
+            .iter_mut()
+            .map(|op| self.simplify_operand(op, location).or_else(|| self.new_opaque()))
+            .collect();
+        let fields = fields?;
+
+        if let AggregateTy::Array = ty && fields.len() > 4 {
+            let first = fields[0];
+            if fields.iter().all(|&v| v == first) {
+                let len = ty::Const::from_target_usize(self.tcx, fields.len().try_into().unwrap());
+                if let Some(const_) = self.try_as_constant(first) {
+                    *rvalue = Rvalue::Repeat(Operand::Constant(Box::new(const_)), len);
+                } else if let Some(local) = self.try_as_local(first, location) {
+                    *rvalue = Rvalue::Repeat(Operand::Copy(local.into()), len);
+                    self.reused_locals.insert(local);
+                }
+                return Some(self.insert(Value::Repeat(first, len)));
+            }
+        }
+
+        Some(self.insert(Value::Aggregate(ty, variant_index, fields)))
+    }
+}
+
+fn op_to_prop_const<'tcx>(
+    ecx: &mut InterpCx<'_, 'tcx, DummyMachine>,
+    op: &OpTy<'tcx>,
+) -> Option<ConstValue<'tcx>> {
+    // Do not attempt to propagate unsized locals.
+    if op.layout.is_unsized() {
+        return None;
+    }
+
+    // This constant is a ZST, just return an empty value.
+    if op.layout.is_zst() {
+        return Some(ConstValue::ZeroSized);
+    }
+
+    // Do not synthetize too large constants. Codegen will just memcpy them, which we'd like to avoid.
+    if !matches!(op.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..)) {
+        return None;
+    }
+
+    // If this constant has scalar ABI, return it as a `ConstValue::Scalar`.
+    if let Abi::Scalar(abi::Scalar::Initialized { .. }) = op.layout.abi
+        && let Ok(scalar) = ecx.read_scalar(op)
+        && scalar.try_to_int().is_ok()
+    {
+        return Some(ConstValue::Scalar(scalar));
+    }
+
+    // If this constant is already represented as an `Allocation`,
+    // try putting it into global memory to return it.
+    if let Either::Left(mplace) = op.as_mplace_or_imm() {
+        let (size, _align) = ecx.size_and_align_of_mplace(&mplace).ok()??;
+
+        // Do not try interning a value that contains provenance.
+        // Due to https://github.com/rust-lang/rust/issues/79738, doing so could lead to bugs.
+        // FIXME: remove this hack once that issue is fixed.
+        let alloc_ref = ecx.get_ptr_alloc(mplace.ptr(), size).ok()??;
+        if alloc_ref.has_provenance() {
+            return None;
+        }
+
+        let pointer = mplace.ptr().into_pointer_or_addr().ok()?;
+        let (alloc_id, offset) = pointer.into_parts();
+        intern_const_alloc_for_constprop(ecx, alloc_id).ok()?;
+        if matches!(ecx.tcx.global_alloc(alloc_id), GlobalAlloc::Memory(_)) {
+            // `alloc_id` may point to a static. Codegen will choke on an `Indirect` with anything
+            // by `GlobalAlloc::Memory`, so do fall through to copying if needed.
+            // FIXME: find a way to treat this more uniformly
+            // (probably by fixing codegen)
+            return Some(ConstValue::Indirect { alloc_id, offset });
+        }
+    }
+
+    // Everything failed: create a new allocation to hold the data.
+    let alloc_id =
+        ecx.intern_with_temp_alloc(op.layout, |ecx, dest| ecx.copy_op(op, dest, false)).ok()?;
+    let value = ConstValue::Indirect { alloc_id, offset: Size::ZERO };
+
+    // Check that we do not leak a pointer.
+    // Those pointers may lose part of their identity in codegen.
+    // FIXME: remove this hack once https://github.com/rust-lang/rust/issues/79738 is fixed.
+    if ecx.tcx.global_alloc(alloc_id).unwrap_memory().inner().provenance().ptrs().is_empty() {
+        return Some(value);
+    }
+
+    None
 }
 
 impl<'tcx> VnState<'_, 'tcx> {
     /// If `index` is a `Value::Constant`, return the `Constant` to be put in the MIR.
     fn try_as_constant(&mut self, index: VnIndex) -> Option<ConstOperand<'tcx>> {
-        if let Value::Constant(const_) = *self.get(index) {
-            // Some constants may contain pointers. We need to preserve the provenance of these
-            // pointers, but not all constants guarantee this:
-            // - valtrees purposefully do not;
-            // - ConstValue::Slice does not either.
-            match const_ {
-                Const::Ty(c) => match c.kind() {
-                    ty::ConstKind::Value(valtree) => match valtree {
-                        // This is just an integer, keep it.
-                        ty::ValTree::Leaf(_) => {}
-                        ty::ValTree::Branch(_) => return None,
-                    },
-                    ty::ConstKind::Param(..)
-                    | ty::ConstKind::Unevaluated(..)
-                    | ty::ConstKind::Expr(..) => {}
-                    // Should not appear in runtime MIR.
-                    ty::ConstKind::Infer(..)
-                    | ty::ConstKind::Bound(..)
-                    | ty::ConstKind::Placeholder(..)
-                    | ty::ConstKind::Error(..) => bug!(),
-                },
-                Const::Unevaluated(..) => {}
-                // If the same slice appears twice in the MIR, we cannot guarantee that we will
-                // give the same `AllocId` to the data.
-                Const::Val(ConstValue::Slice { .. }, _) => return None,
-                Const::Val(
-                    ConstValue::ZeroSized | ConstValue::Scalar(_) | ConstValue::Indirect { .. },
-                    _,
-                ) => {}
-            }
-            Some(ConstOperand { span: rustc_span::DUMMY_SP, user_ty: None, const_ })
-        } else {
-            None
+        // This was already constant in MIR, do not change it.
+        if let Value::Constant { value, disambiguator: _ } = *self.get(index)
+            // If the constant is not deterministic, adding an additional mention of it in MIR will
+            // not give the same value as the former mention.
+            && value.is_deterministic()
+        {
+            return Some(ConstOperand { span: rustc_span::DUMMY_SP, user_ty: None, const_: value });
         }
+
+        let op = self.evaluated[index].as_ref()?;
+        if op.layout.is_unsized() {
+            // Do not attempt to propagate unsized locals.
+            return None;
+        }
+
+        let value = op_to_prop_const(&mut self.ecx, op)?;
+
+        // Check that we do not leak a pointer.
+        // Those pointers may lose part of their identity in codegen.
+        // FIXME: remove this hack once https://github.com/rust-lang/rust/issues/79738 is fixed.
+        assert!(!value.may_have_provenance(self.tcx, op.layout.size));
+
+        let const_ = Const::Val(value, op.layout.ty);
+        Some(ConstOperand { span: rustc_span::DUMMY_SP, user_ty: None, const_ })
     }
 
     /// If there is a local which is assigned `index`, and its assignment strictly dominates `loc`,
@@ -489,27 +995,32 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
         self.tcx
     }
 
+    fn visit_place(&mut self, place: &mut Place<'tcx>, _: PlaceContext, location: Location) {
+        self.simplify_place_projection(place, location);
+    }
+
     fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
         self.simplify_operand(operand, location);
     }
 
     fn visit_statement(&mut self, stmt: &mut Statement<'tcx>, location: Location) {
-        self.super_statement(stmt, location);
         if let StatementKind::Assign(box (_, ref mut rvalue)) = stmt.kind
             // Do not try to simplify a constant, it's already in canonical shape.
             && !matches!(rvalue, Rvalue::Use(Operand::Constant(_)))
-            && 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_)));
-                self.any_replacement = true;
-            } else if let Some(local) = self.try_as_local(value, location)
-                && *rvalue != Rvalue::Use(Operand::Move(local.into()))
+            if let Some(value) = self.simplify_rvalue(rvalue, location)
             {
-                *rvalue = Rvalue::Use(Operand::Copy(local.into()));
-                self.reused_locals.insert(local);
-                self.any_replacement = true;
+                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);
+                }
             }
+        } else {
+            self.super_statement(stmt, location);
         }
     }
 }
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs
index 277060573bc..793dcf0d994 100644
--- a/compiler/rustc_mir_transform/src/inline.rs
+++ b/compiler/rustc_mir_transform/src/inline.rs
@@ -439,6 +439,11 @@ impl<'tcx> Inliner<'tcx> {
         }
 
         if callee_attrs.target_features != self.codegen_fn_attrs.target_features {
+            // In general it is not correct to inline a callee with target features that are a
+            // subset of the caller. This is because the callee might contain calls, and the ABI of
+            // those calls depends on the target features of the surrounding function. By moving a
+            // `Call` terminator from one MIR body to another with more target features, we might
+            // change the ABI of that call!
             return Err("incompatible target features");
         }
 
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs
index 68b8911824c..dc35381fe22 100644
--- a/compiler/rustc_mir_transform/src/lib.rs
+++ b/compiler/rustc_mir_transform/src/lib.rs
@@ -2,6 +2,7 @@
 #![deny(rustc::untranslatable_diagnostic)]
 #![deny(rustc::diagnostic_outside_of_impl)]
 #![feature(box_patterns)]
+#![feature(cow_is_borrowed)]
 #![feature(decl_macro)]
 #![feature(is_sorted)]
 #![feature(let_chains)]
@@ -590,6 +591,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
             &separate_const_switch::SeparateConstSwitch,
             &const_prop::ConstProp,
             &gvn::GVN,
+            &simplify::SimplifyLocals::AfterGVN,
             &dataflow_const_prop::DataflowConstProp,
             &const_debuginfo::ConstDebugInfo,
             &o1(simplify_branches::SimplifyConstCondition::AfterConstProp),
diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs
index 88c89e106fd..0a1c011147a 100644
--- a/compiler/rustc_mir_transform/src/simplify.rs
+++ b/compiler/rustc_mir_transform/src/simplify.rs
@@ -366,6 +366,7 @@ pub fn remove_dead_blocks(body: &mut Body<'_>) {
 
 pub enum SimplifyLocals {
     BeforeConstProp,
+    AfterGVN,
     Final,
 }
 
@@ -373,6 +374,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyLocals {
     fn name(&self) -> &'static str {
         match &self {
             SimplifyLocals::BeforeConstProp => "SimplifyLocals-before-const-prop",
+            SimplifyLocals::AfterGVN => "SimplifyLocals-after-value-numbering",
             SimplifyLocals::Final => "SimplifyLocals-final",
         }
     }
diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl
index e0778f72bfe..9bedd7b8a33 100644
--- a/compiler/rustc_parse/messages.ftl
+++ b/compiler/rustc_parse/messages.ftl
@@ -278,6 +278,9 @@ parse_found_expr_would_be_stmt = expected expression, found `{$token}`
 parse_function_body_equals_expr = function body cannot be `= expression;`
     .suggestion = surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;`
 
+parse_gen_block = `gen` blocks are not yet implemented
+    .help = only the keyword is reserved for now
+
 parse_generic_args_in_pat_require_turbofish_syntax = generic args in patterns require the turbofish syntax
 
 parse_generic_parameters_without_angle_brackets = generic parameters without surrounding angle brackets
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs
index aeb4fd0a304..c0e94d15da0 100644
--- a/compiler/rustc_parse/src/errors.rs
+++ b/compiler/rustc_parse/src/errors.rs
@@ -521,6 +521,14 @@ pub(crate) struct CatchAfterTry {
 }
 
 #[derive(Diagnostic)]
+#[diag(parse_gen_block)]
+#[help]
+pub(crate) struct GenBlock {
+    #[primary_span]
+    pub span: Span,
+}
+
+#[derive(Diagnostic)]
 #[diag(parse_comma_after_base_struct)]
 #[note]
 pub(crate) struct CommaAfterBaseStruct {
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 5157106f4e2..0b5ec9b59ea 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -9,7 +9,7 @@ use super::{
 use crate::errors;
 use crate::maybe_recover_from_interpolated_ty_qpath;
 use ast::mut_visit::{noop_visit_expr, MutVisitor};
-use ast::{Path, PathSegment};
+use ast::{GenBlockKind, Path, PathSegment};
 use core::mem;
 use rustc_ast::ptr::P;
 use rustc_ast::token::{self, Delimiter, Token, TokenKind};
@@ -1441,14 +1441,20 @@ impl<'a> Parser<'a> {
             } else if this.token.uninterpolated_span().at_least_rust_2018() {
                 // `Span:.at_least_rust_2018()` is somewhat expensive; don't get it repeatedly.
                 if this.check_keyword(kw::Async) {
-                    if this.is_async_block() {
+                    if this.is_gen_block(kw::Async) {
                         // Check for `async {` and `async move {`.
-                        this.parse_async_block()
+                        this.parse_gen_block()
                     } else {
                         this.parse_expr_closure()
                     }
                 } else if this.eat_keyword(kw::Await) {
                     this.recover_incorrect_await_syntax(lo, this.prev_token.span)
+                } else if this.token.uninterpolated_span().at_least_rust_2024() {
+                    if this.is_gen_block(kw::Gen) {
+                        this.parse_gen_block()
+                    } else {
+                        this.parse_expr_lit()
+                    }
                 } else {
                     this.parse_expr_lit()
                 }
@@ -1848,7 +1854,7 @@ impl<'a> Parser<'a> {
         let lo = self.prev_token.span;
         let kind = ExprKind::Yield(self.parse_expr_opt()?);
         let span = lo.to(self.prev_token.span);
-        self.sess.gated_spans.gate(sym::coroutines, span);
+        self.sess.gated_spans.gate(sym::yield_expr, span);
         let expr = self.mk_expr(span, kind);
         self.maybe_recover_from_bad_qpath(expr)
     }
@@ -3059,18 +3065,24 @@ impl<'a> Parser<'a> {
             && self.token.uninterpolated_span().at_least_rust_2018()
     }
 
-    /// Parses an `async move? {...}` expression.
-    fn parse_async_block(&mut self) -> PResult<'a, P<Expr>> {
+    /// Parses an `async move? {...}` or `gen move? {...}` expression.
+    fn parse_gen_block(&mut self) -> PResult<'a, P<Expr>> {
         let lo = self.token.span;
-        self.expect_keyword(kw::Async)?;
+        let kind = if self.eat_keyword(kw::Async) {
+            GenBlockKind::Async
+        } else {
+            assert!(self.eat_keyword(kw::Gen));
+            self.sess.gated_spans.gate(sym::gen_blocks, lo.to(self.token.span));
+            GenBlockKind::Gen
+        };
         let capture_clause = self.parse_capture_clause()?;
         let (attrs, body) = self.parse_inner_attrs_and_block()?;
-        let kind = ExprKind::Async(capture_clause, body);
+        let kind = ExprKind::Gen(capture_clause, body, kind);
         Ok(self.mk_expr_with_attrs(lo.to(self.prev_token.span), kind, attrs))
     }
 
-    fn is_async_block(&self) -> bool {
-        self.token.is_keyword(kw::Async)
+    fn is_gen_block(&self, kw: Symbol) -> bool {
+        self.token.is_keyword(kw)
             && ((
                 // `async move {`
                 self.is_keyword_ahead(1, &[kw::Move])
@@ -3596,7 +3608,7 @@ impl MutVisitor for CondChecker<'_> {
             | ExprKind::Match(_, _)
             | ExprKind::Closure(_)
             | ExprKind::Block(_, _)
-            | ExprKind::Async(_, _)
+            | ExprKind::Gen(_, _, _)
             | ExprKind::TryBlock(_)
             | ExprKind::Underscore
             | ExprKind::Path(_, _)
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index 982f601c0d5..a9f456d64cd 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -2297,9 +2297,9 @@ impl<'a> Parser<'a> {
         // `pub` is added in case users got confused with the ordering like `async pub fn`,
         // only if it wasn't preceded by `default` as `default pub` is invalid.
         let quals: &[Symbol] = if check_pub {
-            &[kw::Pub, kw::Const, kw::Async, kw::Unsafe, kw::Extern]
+            &[kw::Pub, kw::Gen, kw::Const, kw::Async, kw::Unsafe, kw::Extern]
         } else {
-            &[kw::Const, kw::Async, kw::Unsafe, kw::Extern]
+            &[kw::Gen, kw::Const, kw::Async, kw::Unsafe, kw::Extern]
         };
         self.check_keyword_case(kw::Fn, case) // Definitely an `fn`.
             // `$qual fn` or `$qual $qual`:
@@ -2353,6 +2353,9 @@ impl<'a> Parser<'a> {
         let async_start_sp = self.token.span;
         let asyncness = self.parse_asyncness(case);
 
+        let _gen_start_sp = self.token.span;
+        let genness = self.parse_genness(case);
+
         let unsafe_start_sp = self.token.span;
         let unsafety = self.parse_unsafety(case);
 
@@ -2368,6 +2371,10 @@ impl<'a> Parser<'a> {
             }
         }
 
+        if let Gen::Yes { span, .. } = genness {
+            self.sess.emit_err(errors::GenBlock { span });
+        }
+
         if !self.eat_keyword_case(kw::Fn, case) {
             // It is possible for `expect_one_of` to recover given the contents of
             // `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't
@@ -2494,9 +2501,11 @@ impl<'a> Parser<'a> {
         // Parse the arguments, starting out with `self` being allowed...
         let (mut params, _) = self.parse_paren_comma_seq(|p| {
             p.recover_diff_marker();
+            let snapshot = p.create_snapshot_for_diagnostic();
             let param = p.parse_param_general(req_name, first_param).or_else(|mut e| {
                 e.emit();
                 let lo = p.prev_token.span;
+                p.restore_snapshot(snapshot);
                 // Skip every token until next possible arg or end.
                 p.eat_to_tokens(&[&token::Comma, &token::CloseDelim(Delimiter::Parenthesis)]);
                 // Create a placeholder argument for proper arg count (issue #34264).
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 41b19ecb63a..59b51954542 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -11,6 +11,7 @@ mod stmt;
 mod ty;
 
 use crate::lexer::UnmatchedDelim;
+use ast::Gen;
 pub use attr_wrapper::AttrWrapper;
 pub use diagnostics::AttemptLocalParseRecovery;
 pub(crate) use expr::ForbiddenLetReason;
@@ -1128,6 +1129,16 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parses genness: `gen` or nothing.
+    fn parse_genness(&mut self, case: Case) -> Gen {
+        if self.token.span.at_least_rust_2024() && self.eat_keyword_case(kw::Gen, case) {
+            let span = self.prev_token.uninterpolated_span();
+            Gen::Yes { span, closure_id: DUMMY_NODE_ID, return_impl_trait_id: DUMMY_NODE_ID }
+        } else {
+            Gen::No
+        }
+    }
+
     /// Parses unsafety: `unsafe` or nothing.
     fn parse_unsafety(&mut self, case: Case) -> Unsafe {
         if self.eat_keyword_case(kw::Unsafe, case) {
diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs
index 24087a4eabb..f915c1057d6 100644
--- a/compiler/rustc_passes/src/hir_stats.rs
+++ b/compiler/rustc_passes/src/hir_stats.rs
@@ -567,10 +567,10 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
             (self, e, e.kind, Id::None, ast, Expr, ExprKind),
             [
                 Array, ConstBlock, Call, MethodCall, Tup, Binary, Unary, Lit, Cast, Type, Let,
-                If, While, ForLoop, Loop, Match, Closure, Block, Async, Await, TryBlock, Assign,
+                If, While, ForLoop, Loop, Match, Closure, Block, Await, TryBlock, Assign,
                 AssignOp, Field, Index, Range, Underscore, Path, AddrOf, Break, Continue, Ret,
                 InlineAsm, FormatArgs, OffsetOf, MacCall, Struct, Repeat, Paren, Try, Yield, Yeet,
-                Become, IncludedBytes, Err
+                Become, IncludedBytes, Gen, Err
             ]
         );
         ast_visit::walk_expr(self, e)
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs
index 356d7f365fe..13df7efe636 100644
--- a/compiler/rustc_resolve/src/def_collector.rs
+++ b/compiler/rustc_resolve/src/def_collector.rs
@@ -260,7 +260,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
                     Async::No => closure_def,
                 }
             }
-            ExprKind::Async(_, _) => self.create_def(expr.id, DefPathData::ClosureExpr, expr.span),
+            ExprKind::Gen(_, _, _) => self.create_def(expr.id, DefPathData::ClosureExpr, expr.span),
             _ => self.parent_def,
         };
 
diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs
index f2fd4b0bf60..1a50bd5ec98 100644
--- a/compiler/rustc_resolve/src/ident.rs
+++ b/compiler/rustc_resolve/src/ident.rs
@@ -1083,7 +1083,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                 for rib in ribs {
                     match rib.kind {
                         RibKind::Normal
-                        | RibKind::ClosureOrAsync
+                        | RibKind::FnOrCoroutine
                         | RibKind::Module(..)
                         | RibKind::MacroDefinition(..)
                         | RibKind::ForwardGenericParamBan => {
@@ -1156,7 +1156,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                 for rib in ribs {
                     let has_generic_params: HasGenericParams = match rib.kind {
                         RibKind::Normal
-                        | RibKind::ClosureOrAsync
+                        | RibKind::FnOrCoroutine
                         | RibKind::Module(..)
                         | RibKind::MacroDefinition(..)
                         | RibKind::InlineAsmSym
@@ -1240,7 +1240,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                 for rib in ribs {
                     let has_generic_params = match rib.kind {
                         RibKind::Normal
-                        | RibKind::ClosureOrAsync
+                        | RibKind::FnOrCoroutine
                         | RibKind::Module(..)
                         | RibKind::MacroDefinition(..)
                         | RibKind::InlineAsmSym
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs
index 42ca407cddf..3be962dab90 100644
--- a/compiler/rustc_resolve/src/late.rs
+++ b/compiler/rustc_resolve/src/late.rs
@@ -177,8 +177,8 @@ pub(crate) enum RibKind<'a> {
     /// upvars).
     AssocItem,
 
-    /// We passed through a closure. Disallow labels.
-    ClosureOrAsync,
+    /// We passed through a function, closure or coroutine signature. Disallow labels.
+    FnOrCoroutine,
 
     /// We passed through an item scope. Disallow upvars.
     Item(HasGenericParams),
@@ -215,7 +215,7 @@ impl RibKind<'_> {
     pub(crate) fn contains_params(&self) -> bool {
         match self {
             RibKind::Normal
-            | RibKind::ClosureOrAsync
+            | RibKind::FnOrCoroutine
             | RibKind::ConstantItem(..)
             | RibKind::Module(_)
             | RibKind::MacroDefinition(_)
@@ -231,7 +231,7 @@ impl RibKind<'_> {
             RibKind::Normal | RibKind::MacroDefinition(..) => false,
 
             RibKind::AssocItem
-            | RibKind::ClosureOrAsync
+            | RibKind::FnOrCoroutine
             | RibKind::Item(..)
             | RibKind::ConstantItem(..)
             | RibKind::Module(..)
@@ -924,9 +924,9 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
         debug!("(resolving function) entering function");
 
         // Create a value rib for the function.
-        self.with_rib(ValueNS, RibKind::ClosureOrAsync, |this| {
+        self.with_rib(ValueNS, RibKind::FnOrCoroutine, |this| {
             // Create a label rib for the function.
-            this.with_label_rib(RibKind::ClosureOrAsync, |this| {
+            this.with_label_rib(RibKind::FnOrCoroutine, |this| {
                 match fn_kind {
                     FnKind::Fn(_, _, sig, _, generics, body) => {
                         this.visit_generics(generics);
@@ -4287,7 +4287,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
                 ..
             }) => {
                 self.with_rib(ValueNS, RibKind::Normal, |this| {
-                    this.with_label_rib(RibKind::ClosureOrAsync, |this| {
+                    this.with_label_rib(RibKind::FnOrCoroutine, |this| {
                         // Resolve arguments:
                         this.resolve_params(&fn_decl.inputs);
                         // No need to resolve return type --
@@ -4304,7 +4304,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
                     })
                 });
             }
-            // For closures, ClosureOrAsyncRibKind is added in visit_fn
+            // For closures, RibKind::FnOrCoroutine is added in visit_fn
             ExprKind::Closure(box ast::Closure {
                 binder: ClosureBinder::For { ref generic_params, span },
                 ..
@@ -4321,8 +4321,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
                 );
             }
             ExprKind::Closure(..) => visit::walk_expr(self, expr),
-            ExprKind::Async(..) => {
-                self.with_label_rib(RibKind::ClosureOrAsync, |this| visit::walk_expr(this, expr));
+            ExprKind::Gen(..) => {
+                self.with_label_rib(RibKind::FnOrCoroutine, |this| visit::walk_expr(this, expr));
             }
             ExprKind::Repeat(ref elem, ref ct) => {
                 self.visit_expr(elem);
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index df92d8262e3..30c8b9d6700 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1899,6 +1899,7 @@ written to standard error output)"),
         `hir` (the HIR), `hir,identified`,
         `hir,typed` (HIR with types for each node),
         `hir-tree` (dump the raw HIR),
+        `thir-tree`, `thir-flat`,
         `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
     unsound_mir_opts: bool = (false, parse_bool, [TRACKED],
         "enable unsound and buggy MIR optimizations (default: no)"),
diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs
index eb868913017..5ab5a048ffa 100644
--- a/compiler/rustc_smir/src/rustc_smir/mod.rs
+++ b/compiler/rustc_smir/src/rustc_smir/mod.rs
@@ -879,18 +879,28 @@ impl<'tcx> Stable<'tcx> for mir::AggregateKind<'tcx> {
     }
 }
 
+impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineSource {
+    type T = stable_mir::mir::CoroutineSource;
+    fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
+        use rustc_hir::CoroutineSource;
+        match self {
+            CoroutineSource::Block => stable_mir::mir::CoroutineSource::Block,
+            CoroutineSource::Closure => stable_mir::mir::CoroutineSource::Closure,
+            CoroutineSource::Fn => stable_mir::mir::CoroutineSource::Fn,
+        }
+    }
+}
+
 impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind {
     type T = stable_mir::mir::CoroutineKind;
-    fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
-        use rustc_hir::{CoroutineKind, CoroutineSource};
+    fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
+        use rustc_hir::CoroutineKind;
         match self {
-            CoroutineKind::Async(async_gen) => {
-                let async_gen = match async_gen {
-                    CoroutineSource::Block => stable_mir::mir::CoroutineSource::Block,
-                    CoroutineSource::Closure => stable_mir::mir::CoroutineSource::Closure,
-                    CoroutineSource::Fn => stable_mir::mir::CoroutineSource::Fn,
-                };
-                stable_mir::mir::CoroutineKind::Async(async_gen)
+            CoroutineKind::Async(source) => {
+                stable_mir::mir::CoroutineKind::Async(source.stable(tables))
+            }
+            CoroutineKind::Gen(source) => {
+                stable_mir::mir::CoroutineKind::Gen(source.stable(tables))
             }
             CoroutineKind::Coroutine => stable_mir::mir::CoroutineKind::Coroutine,
         }
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 88d9dab2ba5..3f99d2a4b1f 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -98,6 +98,7 @@ symbols! {
         Builtin:            "builtin",
         Catch:              "catch",
         Default:            "default",
+        Gen:                "gen",
         MacroRules:         "macro_rules",
         Raw:                "raw",
         Union:              "union",
@@ -225,6 +226,7 @@ symbols! {
         IpAddr,
         IrTyKind,
         Is,
+        Item,
         ItemContext,
         IterEmpty,
         IterOnce,
@@ -818,6 +820,7 @@ symbols! {
         future_trait,
         gdb_script_file,
         ge,
+        gen_blocks,
         gen_future,
         gen_kill,
         generator_clone,
@@ -1779,6 +1782,7 @@ symbols! {
         xmm_reg,
         yeet_desugar_details,
         yeet_expr,
+        yield_expr,
         ymm_reg,
         zmm_reg,
     }
@@ -2189,8 +2193,9 @@ impl Symbol {
         self >= kw::Abstract && self <= kw::Yield
     }
 
-    fn is_unused_keyword_conditional(self, edition: impl FnOnce() -> Edition) -> bool {
-        self == kw::Try && edition() >= Edition::Edition2018
+    fn is_unused_keyword_conditional(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
+        self == kw::Try && edition().at_least_rust_2018()
+            || self == kw::Gen && edition().at_least_rust_2024()
     }
 
     pub fn is_reserved(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
diff --git a/compiler/rustc_target/Cargo.toml b/compiler/rustc_target/Cargo.toml
index a91eb41b18a..779d03cd094 100644
--- a/compiler/rustc_target/Cargo.toml
+++ b/compiler/rustc_target/Cargo.toml
@@ -19,4 +19,4 @@ rustc_index = { path = "../rustc_index" }
 [dependencies.object]
 version = "0.32.0"
 default-features = false
-features = ["elf"]
+features = ["elf", "macho"]
diff --git a/compiler/rustc_target/src/spec/aarch64_apple_tvos_sim.rs b/compiler/rustc_target/src/spec/aarch64_apple_tvos_sim.rs
new file mode 100644
index 00000000000..909a52a5097
--- /dev/null
+++ b/compiler/rustc_target/src/spec/aarch64_apple_tvos_sim.rs
@@ -0,0 +1,31 @@
+use super::apple_base::{opts, tvos_sim_llvm_target, Arch};
+use crate::spec::{FramePointer, Target, TargetOptions};
+
+pub fn target() -> Target {
+    let arch = Arch::Arm64_sim;
+    Target {
+        llvm_target: tvos_sim_llvm_target(arch).into(),
+        pointer_width: 64,
+        data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
+        arch: arch.target_arch(),
+        options: TargetOptions {
+            features: "+neon,+fp-armv8,+apple-a7".into(),
+            max_atomic_width: Some(128),
+            forces_embed_bitcode: true,
+            frame_pointer: FramePointer::NonLeaf,
+            // Taken from (and slightly modified) the aarch64-apple-ios-sim spec which says:
+            // Taken from a clang build on Xcode 11.4.1.
+            // These arguments are not actually invoked - they just have
+            // to look right to pass App Store validation.
+            bitcode_llvm_cmdline: "-triple\0\
+                arm64-apple-tvos15.0-simulator\0\
+                -emit-obj\0\
+                -disable-llvm-passes\0\
+                -target-abi\0\
+                darwinpcs\0\
+                -Os\0"
+                .into(),
+            ..opts("tvos", arch)
+        },
+    }
+}
diff --git a/compiler/rustc_target/src/spec/i586_unknown_netbsd.rs b/compiler/rustc_target/src/spec/i586_unknown_netbsd.rs
new file mode 100644
index 00000000000..0d8bdc3f89f
--- /dev/null
+++ b/compiler/rustc_target/src/spec/i586_unknown_netbsd.rs
@@ -0,0 +1,18 @@
+use crate::spec::{StackProbeType, Target, TargetOptions};
+
+pub fn target() -> Target {
+    let mut base = super::netbsd_base::opts();
+    base.cpu = "pentium".into();
+    base.max_atomic_width = Some(64);
+    base.stack_probes = StackProbeType::Call;
+
+    Target {
+        llvm_target: "i586-unknown-netbsdelf".into(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
+            f64:32:64-f80:32-n8:16:32-S128"
+            .into(),
+        arch: "x86".into(),
+        options: TargetOptions { mcount: "__mcount".into(), ..base },
+    }
+}
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index 3541810d437..ccf29761552 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -1564,6 +1564,7 @@ supported_targets! {
     ("aarch64_be-unknown-netbsd", aarch64_be_unknown_netbsd),
     ("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
     ("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf),
+    ("i586-unknown-netbsd", i586_unknown_netbsd),
     ("i686-unknown-netbsd", i686_unknown_netbsd),
     ("powerpc-unknown-netbsd", powerpc_unknown_netbsd),
     ("riscv64gc-unknown-netbsd", riscv64gc_unknown_netbsd),
@@ -1603,6 +1604,7 @@ supported_targets! {
     ("aarch64-apple-ios-macabi", aarch64_apple_ios_macabi),
     ("aarch64-apple-ios-sim", aarch64_apple_ios_sim),
     ("aarch64-apple-tvos", aarch64_apple_tvos),
+    ("aarch64-apple-tvos-sim", aarch64_apple_tvos_sim),
     ("x86_64-apple-tvos", x86_64_apple_tvos),
 
     ("armv7k-apple-watchos", armv7k_apple_watchos),
diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs
index 6562bc86f99..1ab2bb40af7 100644
--- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs
+++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs
@@ -201,7 +201,15 @@ pub(super) trait GoalKind<'tcx>:
         goal: Goal<'tcx, Self>,
     ) -> QueryResult<'tcx>;
 
-    /// A coroutine (that doesn't come from an `async` desugaring) is known to
+    /// A coroutine (that comes from a `gen` desugaring) is known to implement
+    /// `Iterator<Item = O>`, where `O` is given by the generator's yield type
+    /// that was computed during type-checking.
+    fn consider_builtin_iterator_candidate(
+        ecx: &mut EvalCtxt<'_, 'tcx>,
+        goal: Goal<'tcx, Self>,
+    ) -> QueryResult<'tcx>;
+
+    /// A coroutine (that doesn't come from an `async` or `gen` desugaring) is known to
     /// implement `Coroutine<R, Yield = Y, Return = O>`, given the resume, yield,
     /// and return types of the coroutine computed during type-checking.
     fn consider_builtin_coroutine_candidate(
@@ -554,6 +562,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
             G::consider_builtin_pointee_candidate(self, goal)
         } else if lang_items.future_trait() == Some(trait_def_id) {
             G::consider_builtin_future_candidate(self, goal)
+        } else if lang_items.iterator_trait() == Some(trait_def_id) {
+            G::consider_builtin_iterator_candidate(self, goal)
         } else if lang_items.gen_trait() == Some(trait_def_id) {
             G::consider_builtin_coroutine_candidate(self, goal)
         } else if lang_items.discriminant_kind_trait() == Some(trait_def_id) {
diff --git a/compiler/rustc_trait_selection/src/solve/project_goals/mod.rs b/compiler/rustc_trait_selection/src/solve/project_goals/mod.rs
index be631552c57..240141065dc 100644
--- a/compiler/rustc_trait_selection/src/solve/project_goals/mod.rs
+++ b/compiler/rustc_trait_selection/src/solve/project_goals/mod.rs
@@ -489,6 +489,37 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
         )
     }
 
+    fn consider_builtin_iterator_candidate(
+        ecx: &mut EvalCtxt<'_, 'tcx>,
+        goal: Goal<'tcx, Self>,
+    ) -> QueryResult<'tcx> {
+        let self_ty = goal.predicate.self_ty();
+        let ty::Coroutine(def_id, args, _) = *self_ty.kind() else {
+            return Err(NoSolution);
+        };
+
+        // Coroutines are not Iterators unless they come from `gen` desugaring
+        let tcx = ecx.tcx();
+        if !tcx.coroutine_is_gen(def_id) {
+            return Err(NoSolution);
+        }
+
+        let term = args.as_coroutine().yield_ty().into();
+
+        Self::consider_implied_clause(
+            ecx,
+            goal,
+            ty::ProjectionPredicate {
+                projection_ty: ty::AliasTy::new(ecx.tcx(), goal.predicate.def_id(), [self_ty]),
+                term,
+            }
+            .to_predicate(tcx),
+            // Technically, we need to check that the iterator type is Sized,
+            // but that's already proven by the generator being WF.
+            [],
+        )
+    }
+
     fn consider_builtin_coroutine_candidate(
         ecx: &mut EvalCtxt<'_, 'tcx>,
         goal: Goal<'tcx, Self>,
@@ -500,7 +531,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
 
         // `async`-desugared coroutines do not implement the coroutine trait
         let tcx = ecx.tcx();
-        if tcx.coroutine_is_async(def_id) {
+        if !tcx.is_general_coroutine(def_id) {
             return Err(NoSolution);
         }
 
@@ -527,7 +558,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
                 term,
             }
             .to_predicate(tcx),
-            // Technically, we need to check that the future type is Sized,
+            // Technically, we need to check that the coroutine type is Sized,
             // but that's already proven by the coroutine being WF.
             [],
         )
diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs
index 7c4f6562f10..a0e2ad6e202 100644
--- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs
+++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs
@@ -350,6 +350,30 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
         ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
     }
 
+    fn consider_builtin_iterator_candidate(
+        ecx: &mut EvalCtxt<'_, 'tcx>,
+        goal: Goal<'tcx, Self>,
+    ) -> QueryResult<'tcx> {
+        if goal.predicate.polarity != ty::ImplPolarity::Positive {
+            return Err(NoSolution);
+        }
+
+        let ty::Coroutine(def_id, _, _) = *goal.predicate.self_ty().kind() else {
+            return Err(NoSolution);
+        };
+
+        // Coroutines are not iterators unless they come from `gen` desugaring
+        let tcx = ecx.tcx();
+        if !tcx.coroutine_is_gen(def_id) {
+            return Err(NoSolution);
+        }
+
+        // Gen coroutines unconditionally implement `Iterator`
+        // Technically, we need to check that the iterator output type is Sized,
+        // but that's already proven by the coroutines being WF.
+        ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
+    }
+
     fn consider_builtin_coroutine_candidate(
         ecx: &mut EvalCtxt<'_, 'tcx>,
         goal: Goal<'tcx, Self>,
@@ -365,7 +389,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
 
         // `async`-desugared coroutines do not implement the coroutine trait
         let tcx = ecx.tcx();
-        if tcx.coroutine_is_async(def_id) {
+        if !tcx.is_general_coroutine(def_id) {
             return Err(NoSolution);
         }
 
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index aad07d7683a..31da437f2e9 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -2425,6 +2425,21 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
                         CoroutineKind::Async(CoroutineSource::Closure) => {
                             format!("future created by async closure is not {trait_name}")
                         }
+                        CoroutineKind::Gen(CoroutineSource::Fn) => self
+                            .tcx
+                            .parent(coroutine_did)
+                            .as_local()
+                            .map(|parent_did| hir.local_def_id_to_hir_id(parent_did))
+                            .and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
+                            .map(|name| {
+                                format!("iterator returned by `{name}` is not {trait_name}")
+                            })?,
+                        CoroutineKind::Gen(CoroutineSource::Block) => {
+                            format!("iterator created by gen block is not {trait_name}")
+                        }
+                        CoroutineKind::Gen(CoroutineSource::Closure) => {
+                            format!("iterator created by gen closure is not {trait_name}")
+                        }
                     })
                 })
                 .unwrap_or_else(|| format!("{future_or_coroutine} is not {trait_name}"));
@@ -2931,7 +2946,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
             }
             ObligationCauseCode::SizedCoroutineInterior(coroutine_def_id) => {
                 let what = match self.tcx.coroutine_kind(coroutine_def_id) {
-                    None | Some(hir::CoroutineKind::Coroutine) => "yield",
+                    None | Some(hir::CoroutineKind::Coroutine) | Some(hir::CoroutineKind::Gen(_)) => "yield",
                     Some(hir::CoroutineKind::Async(..)) => "await",
                 };
                 err.note(format!(
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
index af27f5cf4cb..a697c6650b2 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
@@ -1653,6 +1653,9 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
             hir::CoroutineKind::Async(hir::CoroutineSource::Block) => "an async block",
             hir::CoroutineKind::Async(hir::CoroutineSource::Fn) => "an async function",
             hir::CoroutineKind::Async(hir::CoroutineSource::Closure) => "an async closure",
+            hir::CoroutineKind::Gen(hir::CoroutineSource::Block) => "a gen block",
+            hir::CoroutineKind::Gen(hir::CoroutineSource::Fn) => "a gen function",
+            hir::CoroutineKind::Gen(hir::CoroutineSource::Closure) => "a gen closure",
         })
     }
 
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index af30d9121d1..20aa3cec873 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -1798,7 +1798,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
                 let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
 
                 let lang_items = selcx.tcx().lang_items();
-                if [lang_items.gen_trait(), lang_items.future_trait()].contains(&Some(trait_ref.def_id))
+                if [lang_items.gen_trait(), lang_items.future_trait(), lang_items.iterator_trait()].contains(&Some(trait_ref.def_id))
                     || selcx.tcx().fn_trait_kind_from_def_id(trait_ref.def_id).is_some()
                 {
                     true
@@ -2015,6 +2015,8 @@ fn confirm_select_candidate<'cx, 'tcx>(
                 confirm_coroutine_candidate(selcx, obligation, data)
             } else if lang_items.future_trait() == Some(trait_def_id) {
                 confirm_future_candidate(selcx, obligation, data)
+            } else if lang_items.iterator_trait() == Some(trait_def_id) {
+                confirm_iterator_candidate(selcx, obligation, data)
             } else if selcx.tcx().fn_trait_kind_from_def_id(trait_def_id).is_some() {
                 if obligation.predicate.self_ty().is_closure() {
                     confirm_closure_candidate(selcx, obligation, data)
@@ -2135,6 +2137,50 @@ fn confirm_future_candidate<'cx, 'tcx>(
         .with_addl_obligations(obligations)
 }
 
+fn confirm_iterator_candidate<'cx, 'tcx>(
+    selcx: &mut SelectionContext<'cx, 'tcx>,
+    obligation: &ProjectionTyObligation<'tcx>,
+    nested: Vec<PredicateObligation<'tcx>>,
+) -> Progress<'tcx> {
+    let ty::Coroutine(_, args, _) =
+        selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
+    else {
+        unreachable!()
+    };
+    let gen_sig = args.as_coroutine().poly_sig();
+    let Normalized { value: gen_sig, obligations } = normalize_with_depth(
+        selcx,
+        obligation.param_env,
+        obligation.cause.clone(),
+        obligation.recursion_depth + 1,
+        gen_sig,
+    );
+
+    debug!(?obligation, ?gen_sig, ?obligations, "confirm_future_candidate");
+
+    let tcx = selcx.tcx();
+    let iter_def_id = tcx.require_lang_item(LangItem::Iterator, None);
+
+    let predicate = super::util::iterator_trait_ref_and_outputs(
+        tcx,
+        iter_def_id,
+        obligation.predicate.self_ty(),
+        gen_sig,
+    )
+    .map_bound(|(trait_ref, yield_ty)| {
+        debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id).name, sym::Item);
+
+        ty::ProjectionPredicate {
+            projection_ty: ty::AliasTy::new(tcx, obligation.predicate.def_id, trait_ref.args),
+            term: yield_ty.into(),
+        }
+    });
+
+    confirm_param_env_candidate(selcx, obligation, predicate, false)
+        .with_addl_obligations(nested)
+        .with_addl_obligations(obligations)
+}
+
 fn confirm_builtin_candidate<'cx, 'tcx>(
     selcx: &mut SelectionContext<'cx, 'tcx>,
     obligation: &ProjectionTyObligation<'tcx>,
diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
index 123881d9bc6..ee8e1bf7675 100644
--- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
@@ -113,6 +113,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
                     self.assemble_coroutine_candidates(obligation, &mut candidates);
                 } else if lang_items.future_trait() == Some(def_id) {
                     self.assemble_future_candidates(obligation, &mut candidates);
+                } else if lang_items.iterator_trait() == Some(def_id) {
+                    self.assemble_iterator_candidates(obligation, &mut candidates);
                 }
 
                 self.assemble_closure_candidates(obligation, &mut candidates);
@@ -210,9 +212,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
         // type/region parameters.
         let self_ty = obligation.self_ty().skip_binder();
         match self_ty.kind() {
-            // async constructs get lowered to a special kind of coroutine that
+            // `async`/`gen` constructs get lowered to a special kind of coroutine that
             // should *not* `impl Coroutine`.
-            ty::Coroutine(did, ..) if !self.tcx().coroutine_is_async(*did) => {
+            ty::Coroutine(did, ..) if self.tcx().is_general_coroutine(*did) => {
                 debug!(?self_ty, ?obligation, "assemble_coroutine_candidates",);
 
                 candidates.vec.push(CoroutineCandidate);
@@ -242,6 +244,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
         }
     }
 
+    fn assemble_iterator_candidates(
+        &mut self,
+        obligation: &PolyTraitObligation<'tcx>,
+        candidates: &mut SelectionCandidateSet<'tcx>,
+    ) {
+        let self_ty = obligation.self_ty().skip_binder();
+        if let ty::Coroutine(did, ..) = self_ty.kind() {
+            // gen constructs get lowered to a special kind of coroutine that
+            // should directly `impl Iterator`.
+            if self.tcx().coroutine_is_gen(*did) {
+                debug!(?self_ty, ?obligation, "assemble_iterator_candidates",);
+
+                candidates.vec.push(IteratorCandidate);
+            }
+        }
+    }
+
     /// Checks for the artificial impl that the compiler will create for an obligation like `X :
     /// FnMut<..>` where `X` is a closure type.
     ///
diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
index fce439f21fa..952184175f4 100644
--- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
@@ -93,6 +93,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
                 ImplSource::Builtin(BuiltinImplSource::Misc, vtable_future)
             }
 
+            IteratorCandidate => {
+                let vtable_iterator = self.confirm_iterator_candidate(obligation)?;
+                ImplSource::Builtin(BuiltinImplSource::Misc, vtable_iterator)
+            }
+
             FnPointerCandidate { is_const } => {
                 let data = self.confirm_fn_pointer_candidate(obligation, is_const)?;
                 ImplSource::Builtin(BuiltinImplSource::Misc, data)
@@ -780,6 +785,36 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
         Ok(nested)
     }
 
+    fn confirm_iterator_candidate(
+        &mut self,
+        obligation: &PolyTraitObligation<'tcx>,
+    ) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>> {
+        // Okay to skip binder because the args on coroutine types never
+        // touch bound regions, they just capture the in-scope
+        // type/region parameters.
+        let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
+        let ty::Coroutine(coroutine_def_id, args, _) = *self_ty.kind() else {
+            bug!("closure candidate for non-closure {:?}", obligation);
+        };
+
+        debug!(?obligation, ?coroutine_def_id, ?args, "confirm_iterator_candidate");
+
+        let gen_sig = args.as_coroutine().poly_sig();
+
+        let trait_ref = super::util::iterator_trait_ref_and_outputs(
+            self.tcx(),
+            obligation.predicate.def_id(),
+            obligation.predicate.no_bound_vars().expect("iterator has no bound vars").self_ty(),
+            gen_sig,
+        )
+        .map_bound(|(trait_ref, ..)| trait_ref);
+
+        let nested = self.confirm_poly_trait_refs(obligation, trait_ref)?;
+        debug!(?trait_ref, ?nested, "iterator candidate obligations");
+
+        Ok(nested)
+    }
+
     #[instrument(skip(self), level = "debug")]
     fn confirm_closure_candidate(
         &mut self,
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index 67cb39bc004..cf52e6726a1 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -1888,6 +1888,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
                 | ClosureCandidate { .. }
                 | CoroutineCandidate
                 | FutureCandidate
+                | IteratorCandidate
                 | FnPointerCandidate { .. }
                 | BuiltinObjectCandidate
                 | BuiltinUnsizeCandidate
@@ -1916,6 +1917,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
                 | ClosureCandidate { .. }
                 | CoroutineCandidate
                 | FutureCandidate
+                | IteratorCandidate
                 | FnPointerCandidate { .. }
                 | BuiltinObjectCandidate
                 | BuiltinUnsizeCandidate
@@ -1950,6 +1952,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
                 | ClosureCandidate { .. }
                 | CoroutineCandidate
                 | FutureCandidate
+                | IteratorCandidate
                 | FnPointerCandidate { .. }
                 | BuiltinObjectCandidate
                 | BuiltinUnsizeCandidate
@@ -1964,6 +1967,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
                 | ClosureCandidate { .. }
                 | CoroutineCandidate
                 | FutureCandidate
+                | IteratorCandidate
                 | FnPointerCandidate { .. }
                 | BuiltinObjectCandidate
                 | BuiltinUnsizeCandidate
@@ -2070,6 +2074,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
                 | ClosureCandidate { .. }
                 | CoroutineCandidate
                 | FutureCandidate
+                | IteratorCandidate
                 | FnPointerCandidate { .. }
                 | BuiltinObjectCandidate
                 | BuiltinUnsizeCandidate
@@ -2080,6 +2085,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
                 | ClosureCandidate { .. }
                 | CoroutineCandidate
                 | FutureCandidate
+                | IteratorCandidate
                 | FnPointerCandidate { .. }
                 | BuiltinObjectCandidate
                 | BuiltinUnsizeCandidate
diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs
index 67681fb6ec1..bbde0c82743 100644
--- a/compiler/rustc_trait_selection/src/traits/util.rs
+++ b/compiler/rustc_trait_selection/src/traits/util.rs
@@ -297,6 +297,17 @@ pub fn future_trait_ref_and_outputs<'tcx>(
     sig.map_bound(|sig| (trait_ref, sig.return_ty))
 }
 
+pub fn iterator_trait_ref_and_outputs<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    iterator_def_id: DefId,
+    self_ty: Ty<'tcx>,
+    sig: ty::PolyGenSig<'tcx>,
+) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>)> {
+    assert!(!self_ty.has_escaping_bound_vars());
+    let trait_ref = ty::TraitRef::new(tcx, iterator_def_id, [self_ty]);
+    sig.map_bound(|sig| (trait_ref, sig.yield_ty))
+}
+
 pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool {
     assoc_item.defaultness(tcx).is_final()
         && tcx.defaultness(assoc_item.container_id(tcx)).is_final()
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index 0e9d79c15c3..c0fe13ac996 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -258,6 +258,19 @@ fn resolve_associated_item<'tcx>(
                     debug_assert!(tcx.defaultness(trait_item_id).has_value());
                     Some(Instance::new(trait_item_id, rcvr_args))
                 }
+            } else if Some(trait_ref.def_id) == lang_items.iterator_trait() {
+                let ty::Coroutine(coroutine_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
+                    bug!()
+                };
+                if Some(trait_item_id) == tcx.lang_items().next_fn() {
+                    // `Iterator::next` is generated by the compiler.
+                    Some(Instance { def: ty::InstanceDef::Item(coroutine_def_id), args })
+                } else {
+                    // All other methods are default methods of the `Iterator` trait.
+                    // (this assumes that `ImplSource::Builtin` is only used for methods on `Iterator`)
+                    debug_assert!(tcx.defaultness(trait_item_id).has_value());
+                    Some(Instance::new(trait_item_id, rcvr_args))
+                }
             } else if Some(trait_ref.def_id) == lang_items.gen_trait() {
                 let ty::Coroutine(coroutine_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
                     bug!()
diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs
index 50c37e8f910..9f69e61d6fe 100644
--- a/compiler/stable_mir/src/mir/body.rs
+++ b/compiler/stable_mir/src/mir/body.rs
@@ -187,6 +187,7 @@ pub enum UnOp {
 pub enum CoroutineKind {
     Async(CoroutineSource),
     Coroutine,
+    Gen(CoroutineSource),
 }
 
 #[derive(Clone, Debug)]
diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml
index e5f828c4c0b..63aec14f481 100644
--- a/library/alloc/Cargo.toml
+++ b/library/alloc/Cargo.toml
@@ -36,3 +36,5 @@ compiler-builtins-c = ["compiler_builtins/c"]
 compiler-builtins-no-asm = ["compiler_builtins/no-asm"]
 compiler-builtins-mangled-names = ["compiler_builtins/mangled-names"]
 compiler-builtins-weak-intrinsics = ["compiler_builtins/weak-intrinsics"]
+# Make panics and failed asserts immediately abort without formatting any message
+panic_immediate_abort = []
diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs
index a548de814c5..2499f1053d8 100644
--- a/library/alloc/src/alloc.rs
+++ b/library/alloc/src/alloc.rs
@@ -377,13 +377,20 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
         panic!("allocation failed");
     }
 
+    #[inline]
     fn rt_error(layout: Layout) -> ! {
         unsafe {
             __rust_alloc_error_handler(layout.size(), layout.align());
         }
     }
 
-    unsafe { core::intrinsics::const_eval_select((layout,), ct_error, rt_error) }
+    #[cfg(not(feature = "panic_immediate_abort"))]
+    unsafe {
+        core::intrinsics::const_eval_select((layout,), ct_error, rt_error)
+    }
+
+    #[cfg(feature = "panic_immediate_abort")]
+    ct_error(layout)
 }
 
 // For alloc test `std::alloc::handle_alloc_error` can be used directly.
diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs
index 66573b90db9..61c5950b027 100644
--- a/library/alloc/src/collections/binary_heap/mod.rs
+++ b/library/alloc/src/collections/binary_heap/mod.rs
@@ -434,8 +434,9 @@ impl<T: Ord> BinaryHeap<T> {
     /// heap.push(4);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
     #[must_use]
-    pub fn new() -> BinaryHeap<T> {
+    pub const fn new() -> BinaryHeap<T> {
         BinaryHeap { data: vec![] }
     }
 
@@ -477,8 +478,9 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
     /// heap.push(4);
     /// ```
     #[unstable(feature = "allocator_api", issue = "32838")]
+    #[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
     #[must_use]
-    pub fn new_in(alloc: A) -> BinaryHeap<T, A> {
+    pub const fn new_in(alloc: A) -> BinaryHeap<T, A> {
         BinaryHeap { data: Vec::new_in(alloc) }
     }
 
diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs
index 625b67a79ad..bd66ad61219 100644
--- a/library/alloc/src/raw_vec.rs
+++ b/library/alloc/src/raw_vec.rs
@@ -530,7 +530,7 @@ fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
 // ensure that the code generation related to these panics is minimal as there's
 // only one location which panics rather than a bunch throughout the module.
 #[cfg(not(no_global_oom_handling))]
-#[inline(never)]
+#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
 fn capacity_overflow() -> ! {
     panic!("capacity overflow");
 }
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 3b12c1bee0b..6c78d65f1c9 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -1447,7 +1447,8 @@ impl<T, A: Allocator> Vec<T, A> {
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn swap_remove(&mut self, index: usize) -> T {
         #[cold]
-        #[inline(never)]
+        #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
+        #[track_caller]
         fn assert_failed(index: usize, len: usize) -> ! {
             panic!("swap_remove index (is {index}) should be < len (is {len})");
         }
@@ -1488,7 +1489,8 @@ impl<T, A: Allocator> Vec<T, A> {
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn insert(&mut self, index: usize, element: T) {
         #[cold]
-        #[inline(never)]
+        #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
+        #[track_caller]
         fn assert_failed(index: usize, len: usize) -> ! {
             panic!("insertion index (is {index}) should be <= len (is {len})");
         }
@@ -1549,7 +1551,7 @@ impl<T, A: Allocator> Vec<T, A> {
     #[track_caller]
     pub fn remove(&mut self, index: usize) -> T {
         #[cold]
-        #[inline(never)]
+        #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
         #[track_caller]
         fn assert_failed(index: usize, len: usize) -> ! {
             panic!("removal index (is {index}) should be < len (is {len})");
@@ -2148,7 +2150,8 @@ impl<T, A: Allocator> Vec<T, A> {
         A: Clone,
     {
         #[cold]
-        #[inline(never)]
+        #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
+        #[track_caller]
         fn assert_failed(at: usize, len: usize) -> ! {
             panic!("`at` split index (is {at}) should be <= len (is {len})");
         }
diff --git a/library/backtrace b/library/backtrace
-Subproject 99faef833f890fe89f1a959d89b951954118828
+Subproject e9da96eb452aa65e79e2342be700544afe50944
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index f3d8b54d4e9..0978b3c9280 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -755,7 +755,7 @@ impl Display for BorrowMutError {
 }
 
 // This ensures the panicking code is outlined from `borrow_mut` for `RefCell`.
-#[inline(never)]
+#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
 #[track_caller]
 #[cold]
 fn panic_already_borrowed(err: BorrowMutError) -> ! {
@@ -763,7 +763,7 @@ fn panic_already_borrowed(err: BorrowMutError) -> ! {
 }
 
 // This ensures the panicking code is outlined from `borrow` for `RefCell`.
-#[inline(never)]
+#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
 #[track_caller]
 #[cold]
 fn panic_already_mutably_borrowed(err: BorrowError) -> ! {
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs
index e4d6c2c2928..964aa3906f1 100644
--- a/library/core/src/intrinsics.rs
+++ b/library/core/src/intrinsics.rs
@@ -2279,7 +2279,7 @@ extern "rust-intrinsic" {
     /// any safety invariants.
     ///
     /// The stabilized version of this intrinsic is [`core::mem::discriminant`].
-    #[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
+    #[rustc_const_stable(feature = "const_discriminant", since = "CURRENT_RUSTC_VERSION")]
     #[rustc_safe_intrinsic]
     #[rustc_nounwind]
     pub fn discriminant_value<T>(v: &T) -> <T as DiscriminantKind>::Discriminant;
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 0d00899c4de..78df4a8f6e0 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -26,7 +26,8 @@
 //!   assumptions about their semantics: For `memcpy`, `memmove`, `memset`, `memcmp`, and `bcmp`, if
 //!   the `n` parameter is 0, the function is assumed to not be UB. Furthermore, for `memcpy`, if
 //!   source and target pointer are equal, the function is assumed to not be UB.
-//!   (Note that these are [standard assumptions](https://reviews.llvm.org/D86993) among compilers.)
+//!   (Note that these are standard assumptions among compilers:
+//!   [clang](https://reviews.llvm.org/D86993) and [GCC](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667) do the same.)
 //!   These functions are often provided by the system libc, but can also be provided by the
 //!   [compiler-builtins crate](https://crates.io/crates/compiler_builtins).
 //!   Note that the library does not guarantee that it will always make these assumptions, so Rust
@@ -125,7 +126,6 @@
 #![feature(const_caller_location)]
 #![feature(const_cell_into_inner)]
 #![feature(const_char_from_u32_unchecked)]
-#![feature(const_discriminant)]
 #![feature(const_eval_select)]
 #![feature(const_exact_div)]
 #![feature(const_float_bits_conv)]
@@ -291,6 +291,9 @@ pub mod assert_matches {
     pub use crate::macros::{assert_matches, debug_assert_matches};
 }
 
+#[unstable(feature = "cfg_match", issue = "115585")]
+pub use crate::macros::cfg_match;
+
 #[macro_use]
 mod internal_macros;
 
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index c367b53b720..125a6f57bfb 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -168,6 +168,94 @@ pub macro assert_matches {
     },
 }
 
+/// A macro for defining `#[cfg]` match-like statements.
+///
+/// It is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of
+/// `#[cfg]` cases, emitting the implementation which matches first.
+///
+/// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code
+/// without having to rewrite each clause multiple times.
+///
+/// Trailing `_` wildcard match arms are **optional** and they indicate a fallback branch when
+/// all previous declarations do not evaluate to true.
+///
+/// # Example
+///
+/// ```
+/// #![feature(cfg_match)]
+///
+/// cfg_match! {
+///     cfg(unix) => {
+///         fn foo() { /* unix specific functionality */ }
+///     }
+///     cfg(target_pointer_width = "32") => {
+///         fn foo() { /* non-unix, 32-bit functionality */ }
+///     }
+///     _ => {
+///         fn foo() { /* fallback implementation */ }
+///     }
+/// }
+/// ```
+#[unstable(feature = "cfg_match", issue = "115585")]
+#[rustc_diagnostic_item = "cfg_match"]
+pub macro cfg_match {
+    // with a final wildcard
+    (
+        $(cfg($initial_meta:meta) => { $($initial_tokens:item)* })+
+        _ => { $($extra_tokens:item)* }
+    ) => {
+        cfg_match! {
+            @__items ();
+            $((($initial_meta) ($($initial_tokens)*)),)+
+            (() ($($extra_tokens)*)),
+        }
+    },
+
+    // without a final wildcard
+    (
+        $(cfg($extra_meta:meta) => { $($extra_tokens:item)* })*
+    ) => {
+        cfg_match! {
+            @__items ();
+            $((($extra_meta) ($($extra_tokens)*)),)*
+        }
+    },
+
+    // Internal and recursive macro to emit all the items
+    //
+    // Collects all the previous cfgs in a list at the beginning, so they can be
+    // negated. After the semicolon is all the remaining items.
+    (@__items ($($_:meta,)*);) => {},
+    (
+        @__items ($($no:meta,)*);
+        (($($yes:meta)?) ($($tokens:item)*)),
+        $($rest:tt,)*
+    ) => {
+        // Emit all items within one block, applying an appropriate #[cfg]. The
+        // #[cfg] will require all `$yes` matchers specified and must also negate
+        // all previous matchers.
+        #[cfg(all(
+            $($yes,)?
+            not(any($($no),*))
+        ))]
+        cfg_match! { @__identity $($tokens)* }
+
+        // Recurse to emit all other items in `$rest`, and when we do so add all
+        // our `$yes` matchers to the list of `$no` matchers as future emissions
+        // will have to negate everything we just matched as well.
+        cfg_match! {
+            @__items ($($no,)* $($yes,)?);
+            $($rest,)*
+        }
+    },
+
+    // Internal macro to make __apply work out right for different match types,
+    // because of how macros match/expand stuff.
+    (@__identity $($tokens:item)*) => {
+        $($tokens)*
+    }
+}
+
 /// Asserts that a boolean expression is `true` at runtime.
 ///
 /// This will invoke the [`panic!`] macro if the provided expression cannot be
@@ -321,95 +409,6 @@ pub macro debug_assert_matches($($arg:tt)*) {
     }
 }
 
-/// A macro for defining `#[cfg]` match-like statements.
-///
-/// It is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of
-/// `#[cfg]` cases, emitting the implementation which matches first.
-///
-/// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code
-/// without having to rewrite each clause multiple times.
-///
-/// Trailing `_` wildcard match arms are **optional** and they indicate a fallback branch when
-/// all previous declarations do not evaluate to true.
-///
-/// # Example
-///
-/// ```
-/// #![feature(cfg_match)]
-///
-/// cfg_match! {
-///     cfg(unix) => {
-///         fn foo() { /* unix specific functionality */ }
-///     }
-///     cfg(target_pointer_width = "32") => {
-///         fn foo() { /* non-unix, 32-bit functionality */ }
-///     }
-///     _ => {
-///         fn foo() { /* fallback implementation */ }
-///     }
-/// }
-/// ```
-#[macro_export]
-#[unstable(feature = "cfg_match", issue = "115585")]
-#[rustc_diagnostic_item = "cfg_match"]
-macro_rules! cfg_match {
-    // with a final wildcard
-    (
-        $(cfg($initial_meta:meta) => { $($initial_tokens:item)* })+
-        _ => { $($extra_tokens:item)* }
-    ) => {
-        cfg_match! {
-            @__items ();
-            $((($initial_meta) ($($initial_tokens)*)),)+
-            (() ($($extra_tokens)*)),
-        }
-    };
-
-    // without a final wildcard
-    (
-        $(cfg($extra_meta:meta) => { $($extra_tokens:item)* })*
-    ) => {
-        cfg_match! {
-            @__items ();
-            $((($extra_meta) ($($extra_tokens)*)),)*
-        }
-    };
-
-    // Internal and recursive macro to emit all the items
-    //
-    // Collects all the previous cfgs in a list at the beginning, so they can be
-    // negated. After the semicolon is all the remaining items.
-    (@__items ($($_:meta,)*);) => {};
-    (
-        @__items ($($no:meta,)*);
-        (($($yes:meta)?) ($($tokens:item)*)),
-        $($rest:tt,)*
-    ) => {
-        // Emit all items within one block, applying an appropriate #[cfg]. The
-        // #[cfg] will require all `$yes` matchers specified and must also negate
-        // all previous matchers.
-        #[cfg(all(
-            $($yes,)?
-            not(any($($no),*))
-        ))]
-        cfg_match! { @__identity $($tokens)* }
-
-        // Recurse to emit all other items in `$rest`, and when we do so add all
-        // our `$yes` matchers to the list of `$no` matchers as future emissions
-        // will have to negate everything we just matched as well.
-        cfg_match! {
-            @__items ($($no,)* $($yes,)?);
-            $($rest,)*
-        }
-    };
-
-    // Internal macro to make __apply work out right for different match types,
-    // because of how macros match/expand stuff.
-    (@__identity $($tokens:item)*) => {
-        $($tokens)*
-    };
-}
-
 /// Returns whether the given expression matches any of the given patterns.
 ///
 /// Like in a `match` expression, the pattern can be optionally followed by `if`
diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs
index 7ef84b0f5b5..df79c3a338a 100644
--- a/library/core/src/mem/mod.rs
+++ b/library/core/src/mem/mod.rs
@@ -1206,7 +1206,7 @@ impl<T> fmt::Debug for Discriminant<T> {
 /// // assert_eq!(0, unsafe { std::mem::transmute::<_, u8>(std::mem::discriminant(&unit_like)) });
 /// ```
 #[stable(feature = "discriminant_value", since = "1.21.0")]
-#[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
+#[rustc_const_stable(feature = "const_discriminant", since = "CURRENT_RUSTC_VERSION")]
 #[cfg_attr(not(test), rustc_diagnostic_item = "mem_discriminant")]
 #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
 pub const fn discriminant<T>(v: &T) -> Discriminant<T> {
diff --git a/library/core/src/panic/unwind_safe.rs b/library/core/src/panic/unwind_safe.rs
index 7e7b6b4dbe9..6a53909a8f1 100644
--- a/library/core/src/panic/unwind_safe.rs
+++ b/library/core/src/panic/unwind_safe.rs
@@ -267,6 +267,7 @@ impl<T> DerefMut for AssertUnwindSafe<T> {
 impl<R, F: FnOnce() -> R> FnOnce<()> for AssertUnwindSafe<F> {
     type Output = R;
 
+    #[inline]
     extern "rust-call" fn call_once(self, _args: ()) -> R {
         (self.0)()
     }
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index 6aba9b64509..27178328be5 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -81,6 +81,7 @@ use iter::{MatchesInternal, SplitNInternal};
 #[cold]
 #[track_caller]
 #[rustc_allow_const_fn_unstable(const_eval_select)]
+#[cfg(not(feature = "panic_immediate_abort"))]
 const fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! {
     // SAFETY: panics for both branches
     unsafe {
@@ -92,6 +93,11 @@ const fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! {
     }
 }
 
+#[cfg(feature = "panic_immediate_abort")]
+const fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! {
+    slice_error_fail_ct(s, begin, end)
+}
+
 #[track_caller]
 const fn slice_error_fail_ct(_: &str, _: usize, _: usize) -> ! {
     panic!("failed to slice string");
diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
index 3b57f864e20..2eb7608c7ae 100644
--- a/library/std/Cargo.toml
+++ b/library/std/Cargo.toml
@@ -72,7 +72,7 @@ llvm-libunwind = ["unwind/llvm-libunwind"]
 system-llvm-libunwind = ["unwind/system-llvm-libunwind"]
 
 # Make panics and failed asserts immediately abort without formatting any message
-panic_immediate_abort = ["core/panic_immediate_abort"]
+panic_immediate_abort = ["core/panic_immediate_abort", "alloc/panic_immediate_abort"]
 
 # Enable std_detect default features for stdarch/crates/std_detect:
 # https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml
diff --git a/library/std/src/os/linux/fs.rs b/library/std/src/os/linux/fs.rs
index 479bbcc17a8..ab0b2a3eda3 100644
--- a/library/std/src/os/linux/fs.rs
+++ b/library/std/src/os/linux/fs.rs
@@ -329,7 +329,14 @@ pub trait MetadataExt {
 impl MetadataExt for Metadata {
     #[allow(deprecated)]
     fn as_raw_stat(&self) -> &raw::stat {
-        unsafe { &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat) }
+        #[cfg(target_env = "musl")]
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat)
+        }
+        #[cfg(not(target_env = "musl"))]
+        unsafe {
+            &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat)
+        }
     }
     fn st_dev(&self) -> u64 {
         self.as_inner().as_inner().st_dev as u64
diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs
index d7a2baa1ff5..55f4917a937 100644
--- a/library/std/src/panicking.rs
+++ b/library/std/src/panicking.rs
@@ -295,12 +295,53 @@ fn default_hook(info: &PanicInfo<'_>) {
 
 #[cfg(not(test))]
 #[doc(hidden)]
+#[cfg(feature = "panic_immediate_abort")]
+#[unstable(feature = "update_panic_count", issue = "none")]
+pub mod panic_count {
+    /// A reason for forcing an immediate abort on panic.
+    #[derive(Debug)]
+    pub enum MustAbort {
+        AlwaysAbort,
+        PanicInHook,
+    }
+
+    #[inline]
+    pub fn increase(run_panic_hook: bool) -> Option<MustAbort> {
+        None
+    }
+
+    #[inline]
+    pub fn finished_panic_hook() {}
+
+    #[inline]
+    pub fn decrease() {}
+
+    #[inline]
+    pub fn set_always_abort() {}
+
+    // Disregards ALWAYS_ABORT_FLAG
+    #[inline]
+    #[must_use]
+    pub fn get_count() -> usize {
+        0
+    }
+
+    #[must_use]
+    #[inline]
+    pub fn count_is_zero() -> bool {
+        true
+    }
+}
+
+#[cfg(not(test))]
+#[doc(hidden)]
+#[cfg(not(feature = "panic_immediate_abort"))]
 #[unstable(feature = "update_panic_count", issue = "none")]
 pub mod panic_count {
     use crate::cell::Cell;
     use crate::sync::atomic::{AtomicUsize, Ordering};
 
-    pub const ALWAYS_ABORT_FLAG: usize = 1 << (usize::BITS - 1);
+    const ALWAYS_ABORT_FLAG: usize = 1 << (usize::BITS - 1);
 
     /// A reason for forcing an immediate abort on panic.
     #[derive(Debug)]
@@ -421,6 +462,13 @@ pub mod panic_count {
 pub use realstd::rt::panic_count;
 
 /// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
+#[cfg(feature = "panic_immediate_abort")]
+pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
+    Ok(f())
+}
+
+/// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
+#[cfg(not(feature = "panic_immediate_abort"))]
 pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
     union Data<F, R> {
         f: ManuallyDrop<F>,
@@ -755,6 +803,7 @@ fn rust_panic_with_hook(
 
 /// This is the entry point for `resume_unwind`.
 /// It just forwards the payload to the panic runtime.
+#[cfg_attr(feature = "panic_immediate_abort", inline)]
 pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
     panic_count::increase(false);
 
@@ -777,7 +826,16 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
 /// yer breakpoints.
 #[inline(never)]
 #[cfg_attr(not(test), rustc_std_internal_symbol)]
+#[cfg(not(feature = "panic_immediate_abort"))]
 fn rust_panic(msg: &mut dyn PanicPayload) -> ! {
     let code = unsafe { __rust_start_panic(msg) };
     rtabort!("failed to initiate panic, error {code}")
 }
+
+#[cfg_attr(not(test), rustc_std_internal_symbol)]
+#[cfg(feature = "panic_immediate_abort")]
+fn rust_panic(_: &mut dyn PanicPayload) -> ! {
+    unsafe {
+        crate::intrinsics::abort();
+    }
+}
diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs
index 6c4f408426a..bf1fb3123c4 100644
--- a/library/std/src/sys/unix/fd.rs
+++ b/library/std/src/sys/unix/fd.rs
@@ -126,9 +126,17 @@ impl FileDesc {
     }
 
     pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
-        #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "hurd")))]
+        #[cfg(not(any(
+            all(target_os = "linux", not(target_env = "musl")),
+            target_os = "android",
+            target_os = "hurd"
+        )))]
         use libc::pread as pread64;
-        #[cfg(any(target_os = "linux", target_os = "android", target_os = "hurd"))]
+        #[cfg(any(
+            all(target_os = "linux", not(target_env = "musl")),
+            target_os = "android",
+            target_os = "hurd"
+        ))]
         use libc::pread64;
 
         unsafe {
@@ -285,9 +293,17 @@ impl FileDesc {
     }
 
     pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
-        #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "hurd")))]
+        #[cfg(not(any(
+            all(target_os = "linux", not(target_env = "musl")),
+            target_os = "android",
+            target_os = "hurd"
+        )))]
         use libc::pwrite as pwrite64;
-        #[cfg(any(target_os = "linux", target_os = "android", target_os = "hurd"))]
+        #[cfg(any(
+            all(target_os = "linux", not(target_env = "musl")),
+            target_os = "android",
+            target_os = "hurd"
+        ))]
         use libc::pwrite64;
 
         unsafe {
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
index e1c58f2ba3c..40eb910fdc3 100644
--- a/library/std/src/sys/unix/fs.rs
+++ b/library/std/src/sys/unix/fs.rs
@@ -40,13 +40,17 @@ use libc::{c_int, mode_t};
 ))]
 use libc::c_char;
 #[cfg(any(
-    target_os = "linux",
+    all(target_os = "linux", not(target_env = "musl")),
     target_os = "emscripten",
     target_os = "android",
-    target_os = "hurd",
+    target_os = "hurd"
 ))]
 use libc::dirfd;
-#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "hurd"))]
+#[cfg(any(
+    all(target_os = "linux", not(target_env = "musl")),
+    target_os = "emscripten",
+    target_os = "hurd"
+))]
 use libc::fstatat64;
 #[cfg(any(
     target_os = "android",
@@ -57,9 +61,10 @@ use libc::fstatat64;
     target_os = "aix",
     target_os = "nto",
     target_os = "vita",
+    all(target_os = "linux", target_env = "musl"),
 ))]
 use libc::readdir as readdir64;
-#[cfg(any(target_os = "linux", target_os = "hurd"))]
+#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
 use libc::readdir64;
 #[cfg(any(target_os = "emscripten", target_os = "l4re"))]
 use libc::readdir64_r;
@@ -84,7 +89,7 @@ use libc::{
     lstat as lstat64, off64_t, open as open64, stat as stat64,
 };
 #[cfg(not(any(
-    target_os = "linux",
+    all(target_os = "linux", not(target_env = "musl")),
     target_os = "emscripten",
     target_os = "l4re",
     target_os = "android",
@@ -95,7 +100,7 @@ use libc::{
     lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
 };
 #[cfg(any(
-    target_os = "linux",
+    all(target_os = "linux", not(target_env = "musl")),
     target_os = "emscripten",
     target_os = "l4re",
     target_os = "hurd"
@@ -853,10 +858,10 @@ impl DirEntry {
 
     #[cfg(all(
         any(
-            target_os = "linux",
+            all(target_os = "linux", not(target_env = "musl")),
             target_os = "emscripten",
             target_os = "android",
-            target_os = "hurd",
+            target_os = "hurd"
         ),
         not(miri)
     ))]
@@ -882,7 +887,7 @@ impl DirEntry {
 
     #[cfg(any(
         not(any(
-            target_os = "linux",
+            all(target_os = "linux", not(target_env = "musl")),
             target_os = "emscripten",
             target_os = "android",
             target_os = "hurd",
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index 5b5334b0a55..f56e46010f3 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -1274,8 +1274,9 @@ impl Config {
         }
 
         config.initial_rustc = if let Some(rustc) = build.rustc {
-            // FIXME(#115065): re-enable this check
-            // config.check_build_rustc_version(&rustc);
+            if !flags.skip_stage0_validation {
+                config.check_build_rustc_version(&rustc);
+            }
             PathBuf::from(rustc)
         } else {
             config.download_beta_toolchain();
diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs
index dea55303544..64af114f998 100644
--- a/src/bootstrap/src/core/config/flags.rs
+++ b/src/bootstrap/src/core/config/flags.rs
@@ -155,6 +155,9 @@ pub struct Flags {
     /// Enable BOLT link flags
     #[arg(global(true), long)]
     pub enable_bolt_settings: bool,
+    /// Skip stage0 compiler validation
+    #[arg(global(true), long)]
+    pub skip_stage0_validation: bool,
     /// Additional reproducible artifacts that should be added to the reproducible artifacts archive.
     #[arg(global(true), long)]
     pub reproducible_artifact: Vec<String>,
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index 8dd1a698dfa..d7f49a6d11b 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -586,7 +586,11 @@ impl Build {
                     .args(&["diff-index", "--quiet", "HEAD"])
                     .current_dir(&absolute_path),
             )
-            .allow_failure(),
+            .allow_failure()
+            .output_mode(match self.is_verbose() {
+                true => OutputMode::PrintAll,
+                false => OutputMode::PrintOutput,
+            }),
         );
         if has_local_modifications {
             self.run(Command::new("git").args(&["stash", "push"]).current_dir(&absolute_path));
diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs
index 9c1c21cd958..0aede2022ba 100644
--- a/src/bootstrap/src/utils/exec.rs
+++ b/src/bootstrap/src/utils/exec.rs
@@ -54,7 +54,7 @@ impl<'a> From<&'a mut Command> for BootstrapCommand<'a> {
         Self {
             command,
             failure_behavior: BehaviorOnFailure::Exit,
-            output_mode: OutputMode::SuppressOnSuccess,
+            output_mode: OutputMode::PrintAll,
         }
     }
 }
diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md
index 4e55d360430..68ec0f348dc 100644
--- a/src/doc/rustc/src/platform-support.md
+++ b/src/doc/rustc/src/platform-support.md
@@ -152,6 +152,7 @@ target | std | notes
 `i586-pc-windows-msvc` | * | 32-bit Windows w/o SSE [^x86_32-floats-x87]
 `i586-unknown-linux-gnu` | ✓ | 32-bit Linux w/o SSE (kernel 3.2, glibc 2.17) [^x86_32-floats-x87]
 `i586-unknown-linux-musl` | ✓ | 32-bit Linux w/o SSE, MUSL [^x86_32-floats-x87]
+[`i586-unknown-netbsd`](platform-support/netbsd.md) |  ✓ | 32-bit x86, restricted to Pentium
 [`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android [^x86_32-floats-return-ABI]
 `i686-unknown-freebsd` | ✓ | 32-bit FreeBSD [^x86_32-floats-return-ABI]
 `i686-unknown-linux-musl` | ✓ | 32-bit Linux with MUSL [^x86_32-floats-return-ABI]
@@ -217,6 +218,7 @@ target | std | host | notes
 -------|:---:|:----:|-------
 `aarch64-apple-ios-macabi` | ? |  | Apple Catalyst on ARM64
 [`aarch64-apple-tvos`](platform-support/apple-tvos.md) | ? |  | ARM64 tvOS
+[`aarch64-apple-tvos-sim`](platform-support/apple-tvos.md) | ? |  | ARM64 tvOS Simulator
 [`aarch64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ |  | ARM64 Apple WatchOS Simulator
 [`aarch64-kmc-solid_asp3`](platform-support/kmc-solid.md) | ✓ |  | ARM64 SOLID with TOPPERS/ASP3
 [`aarch64-nintendo-switch-freestanding`](platform-support/aarch64-nintendo-switch-freestanding.md) | * |  | ARM64 Nintendo Switch, Horizon
diff --git a/src/doc/rustc/src/platform-support/apple-tvos.md b/src/doc/rustc/src/platform-support/apple-tvos.md
index d87fd1959b4..e7ea109df1b 100644
--- a/src/doc/rustc/src/platform-support/apple-tvos.md
+++ b/src/doc/rustc/src/platform-support/apple-tvos.md
@@ -52,7 +52,7 @@ The targets can be built by enabling them for a `rustc` build in `config.toml`,
 ```toml
 [build]
 build-stage = 1
-target = ["aarch64-apple-tvos", "x86_64-apple-tvos"]
+target = ["aarch64-apple-tvos", "x86_64-apple-tvos", "aarch64-apple-tvos-sim"]
 ```
 
 It's possible that cargo under `-Zbuild-std` may also be used to target them.
@@ -67,6 +67,8 @@ Rust programs can be built for these targets
 $ rustc --target aarch64-apple-tvos your-code.rs
 ...
 $ rustc --target x86_64-apple-tvos your-code.rs
+...
+$ rustc --target aarch64-apple-tvos-sim your-code.rs
 ```
 
 ## Testing
diff --git a/src/etc/completions/x.py.fish b/src/etc/completions/x.py.fish
index 85fcc37fd81..48796988868 100644
--- a/src/etc/completions/x.py.fish
+++ b/src/etc/completions/x.py.fish
@@ -28,6 +28,7 @@ complete -c x.py -n "__fish_use_subcommand" -l dry-run -d 'dry run; don\'t build
 complete -c x.py -n "__fish_use_subcommand" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_use_subcommand" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_use_subcommand" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_use_subcommand" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_use_subcommand" -s h -l help -d 'Print help'
 complete -c x.py -n "__fish_use_subcommand" -f -a "build" -d 'Compile either the compiler or libraries'
 complete -c x.py -n "__fish_use_subcommand" -f -a "check" -d 'Compile either the compiler or libraries, using cargo check'
@@ -73,6 +74,7 @@ complete -c x.py -n "__fish_seen_subcommand_from build" -l dry-run -d 'dry run;
 complete -c x.py -n "__fish_seen_subcommand_from build" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from build" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from build" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from build" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from build" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from check" -l config -d 'TOML configuration file for build' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from check" -l build-dir -d 'Build directory, overrides `build.build-dir` in `config.toml`' -r -f -a "(__fish_complete_directories)"
@@ -105,6 +107,7 @@ complete -c x.py -n "__fish_seen_subcommand_from check" -l dry-run -d 'dry run;
 complete -c x.py -n "__fish_seen_subcommand_from check" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from check" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from check" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from check" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from check" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from clippy" -s A -d 'clippy lints to allow' -r
 complete -c x.py -n "__fish_seen_subcommand_from clippy" -s D -d 'clippy lints to deny' -r
@@ -141,6 +144,7 @@ complete -c x.py -n "__fish_seen_subcommand_from clippy" -l dry-run -d 'dry run;
 complete -c x.py -n "__fish_seen_subcommand_from clippy" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from clippy" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from clippy" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from clippy" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from clippy" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from fix" -l config -d 'TOML configuration file for build' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from fix" -l build-dir -d 'Build directory, overrides `build.build-dir` in `config.toml`' -r -f -a "(__fish_complete_directories)"
@@ -172,6 +176,7 @@ complete -c x.py -n "__fish_seen_subcommand_from fix" -l dry-run -d 'dry run; do
 complete -c x.py -n "__fish_seen_subcommand_from fix" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from fix" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from fix" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from fix" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from fix" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from fmt" -l config -d 'TOML configuration file for build' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from fmt" -l build-dir -d 'Build directory, overrides `build.build-dir` in `config.toml`' -r -f -a "(__fish_complete_directories)"
@@ -204,6 +209,7 @@ complete -c x.py -n "__fish_seen_subcommand_from fmt" -l dry-run -d 'dry run; do
 complete -c x.py -n "__fish_seen_subcommand_from fmt" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from fmt" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from fmt" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from fmt" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from fmt" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from doc" -l config -d 'TOML configuration file for build' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from doc" -l build-dir -d 'Build directory, overrides `build.build-dir` in `config.toml`' -r -f -a "(__fish_complete_directories)"
@@ -237,6 +243,7 @@ complete -c x.py -n "__fish_seen_subcommand_from doc" -l dry-run -d 'dry run; do
 complete -c x.py -n "__fish_seen_subcommand_from doc" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from doc" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from doc" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from doc" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from doc" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from test" -l skip -d 'skips tests matching SUBSTRING, if supported by test tool. May be passed multiple times' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from test" -l test-args -d 'extra arguments to be passed for the test tool being used (e.g. libtest, compiletest or rustdoc)' -r
@@ -281,6 +288,7 @@ complete -c x.py -n "__fish_seen_subcommand_from test" -l dry-run -d 'dry run; d
 complete -c x.py -n "__fish_seen_subcommand_from test" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from test" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from test" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from test" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from test" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from bench" -l test-args -r
 complete -c x.py -n "__fish_seen_subcommand_from bench" -l config -d 'TOML configuration file for build' -r -F
@@ -313,6 +321,7 @@ complete -c x.py -n "__fish_seen_subcommand_from bench" -l dry-run -d 'dry run;
 complete -c x.py -n "__fish_seen_subcommand_from bench" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from bench" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from bench" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from bench" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from bench" -s h -l help -d 'Print help'
 complete -c x.py -n "__fish_seen_subcommand_from clean" -l stage -d 'Clean a specific stage without touching other artifacts. By default, every stage is cleaned if this option is not used' -r
 complete -c x.py -n "__fish_seen_subcommand_from clean" -l config -d 'TOML configuration file for build' -r -F
@@ -345,6 +354,7 @@ complete -c x.py -n "__fish_seen_subcommand_from clean" -l dry-run -d 'dry run;
 complete -c x.py -n "__fish_seen_subcommand_from clean" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from clean" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from clean" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from clean" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from clean" -s h -l help -d 'Print help'
 complete -c x.py -n "__fish_seen_subcommand_from dist" -l config -d 'TOML configuration file for build' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from dist" -l build-dir -d 'Build directory, overrides `build.build-dir` in `config.toml`' -r -f -a "(__fish_complete_directories)"
@@ -376,6 +386,7 @@ complete -c x.py -n "__fish_seen_subcommand_from dist" -l dry-run -d 'dry run; d
 complete -c x.py -n "__fish_seen_subcommand_from dist" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from dist" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from dist" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from dist" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from dist" -s h -l help -d 'Print help'
 complete -c x.py -n "__fish_seen_subcommand_from install" -l config -d 'TOML configuration file for build' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from install" -l build-dir -d 'Build directory, overrides `build.build-dir` in `config.toml`' -r -f -a "(__fish_complete_directories)"
@@ -407,6 +418,7 @@ complete -c x.py -n "__fish_seen_subcommand_from install" -l dry-run -d 'dry run
 complete -c x.py -n "__fish_seen_subcommand_from install" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from install" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from install" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from install" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from install" -s h -l help -d 'Print help'
 complete -c x.py -n "__fish_seen_subcommand_from run" -l args -d 'arguments for the tool' -r
 complete -c x.py -n "__fish_seen_subcommand_from run" -l config -d 'TOML configuration file for build' -r -F
@@ -439,6 +451,7 @@ complete -c x.py -n "__fish_seen_subcommand_from run" -l dry-run -d 'dry run; do
 complete -c x.py -n "__fish_seen_subcommand_from run" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from run" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from run" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from run" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from run" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from setup" -l config -d 'TOML configuration file for build' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from setup" -l build-dir -d 'Build directory, overrides `build.build-dir` in `config.toml`' -r -f -a "(__fish_complete_directories)"
@@ -470,6 +483,7 @@ complete -c x.py -n "__fish_seen_subcommand_from setup" -l dry-run -d 'dry run;
 complete -c x.py -n "__fish_seen_subcommand_from setup" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from setup" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from setup" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from setup" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from setup" -s h -l help -d 'Print help (see more with \'--help\')'
 complete -c x.py -n "__fish_seen_subcommand_from suggest" -l config -d 'TOML configuration file for build' -r -F
 complete -c x.py -n "__fish_seen_subcommand_from suggest" -l build-dir -d 'Build directory, overrides `build.build-dir` in `config.toml`' -r -f -a "(__fish_complete_directories)"
@@ -502,4 +516,5 @@ complete -c x.py -n "__fish_seen_subcommand_from suggest" -l dry-run -d 'dry run
 complete -c x.py -n "__fish_seen_subcommand_from suggest" -l json-output -d 'use message-format=json'
 complete -c x.py -n "__fish_seen_subcommand_from suggest" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
 complete -c x.py -n "__fish_seen_subcommand_from suggest" -l enable-bolt-settings -d 'Enable BOLT link flags'
+complete -c x.py -n "__fish_seen_subcommand_from suggest" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
 complete -c x.py -n "__fish_seen_subcommand_from suggest" -s h -l help -d 'Print help (see more with \'--help\')'
diff --git a/src/etc/completions/x.py.ps1 b/src/etc/completions/x.py.ps1
index 07e1b0ace9d..2fed1be7269 100644
--- a/src/etc/completions/x.py.ps1
+++ b/src/etc/completions/x.py.ps1
@@ -54,6 +54,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
             [CompletionResult]::new('build', 'build', [CompletionResultType]::ParameterValue, 'Compile either the compiler or libraries')
@@ -106,6 +107,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -145,6 +147,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -188,6 +191,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -226,6 +230,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -265,6 +270,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -305,6 +311,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -356,6 +363,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -395,6 +403,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
             break
@@ -434,6 +443,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
             break
@@ -472,6 +482,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
             break
@@ -510,6 +521,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
             break
@@ -549,6 +561,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -587,6 +600,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
@@ -626,6 +640,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
             [CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
             [CompletionResult]::new('--llvm-profile-generate', 'llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
             [CompletionResult]::new('--enable-bolt-settings', 'enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
+            [CompletionResult]::new('--skip-stage0-validation', 'skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
             [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
             break
diff --git a/src/etc/completions/x.py.sh b/src/etc/completions/x.py.sh
index 241bc058e7b..f22d7e3e131 100644
--- a/src/etc/completions/x.py.sh
+++ b/src/etc/completions/x.py.sh
@@ -61,7 +61,7 @@ _x.py() {
 
     case "${cmd}" in
         x.py)
-            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]... build check clippy fix fmt doc test bench clean dist install run setup suggest"
+            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]... build check clippy fix fmt doc test bench clean dist install run setup suggest"
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -171,7 +171,7 @@ _x.py() {
             return 0
             ;;
         x.py__bench)
-            opts="-v -i -j -h --test-args --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --test-args --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -285,7 +285,7 @@ _x.py() {
             return 0
             ;;
         x.py__build)
-            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -395,7 +395,7 @@ _x.py() {
             return 0
             ;;
         x.py__check)
-            opts="-v -i -j -h --all-targets --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --all-targets --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -505,7 +505,7 @@ _x.py() {
             return 0
             ;;
         x.py__clean)
-            opts="-v -i -j -h --all --stage --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --all --stage --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -615,7 +615,7 @@ _x.py() {
             return 0
             ;;
         x.py__clippy)
-            opts="-A -D -W -F -v -i -j -h --fix --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-A -D -W -F -v -i -j -h --fix --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -741,7 +741,7 @@ _x.py() {
             return 0
             ;;
         x.py__dist)
-            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -851,7 +851,7 @@ _x.py() {
             return 0
             ;;
         x.py__doc)
-            opts="-v -i -j -h --open --json --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --open --json --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -961,7 +961,7 @@ _x.py() {
             return 0
             ;;
         x.py__fix)
-            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -1071,7 +1071,7 @@ _x.py() {
             return 0
             ;;
         x.py__fmt)
-            opts="-v -i -j -h --check --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --check --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -1181,7 +1181,7 @@ _x.py() {
             return 0
             ;;
         x.py__install)
-            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -1291,7 +1291,7 @@ _x.py() {
             return 0
             ;;
         x.py__run)
-            opts="-v -i -j -h --args --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --args --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -1405,7 +1405,7 @@ _x.py() {
             return 0
             ;;
         x.py__setup)
-            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [<PROFILE>|hook|vscode|link] [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [<PROFILE>|hook|vscode|link] [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -1515,7 +1515,7 @@ _x.py() {
             return 0
             ;;
         x.py__suggest)
-            opts="-v -i -j -h --run --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --run --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
@@ -1625,7 +1625,7 @@ _x.py() {
             return 0
             ;;
         x.py__test)
-            opts="-v -i -j -h --no-fail-fast --skip --test-args --rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --verbose --incremental --config --build-dir --build --host --target --exclude --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --reproducible-artifact --set --help [PATHS]... [ARGS]..."
+            opts="-v -i -j -h --no-fail-fast --skip --test-args --rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --verbose --incremental --config --build-dir --build --host --target --exclude --include-default-paths --rustc-error-format --on-fail --dry-run --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --llvm-skip-rebuild --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [PATHS]... [ARGS]..."
             if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                 COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                 return 0
diff --git a/src/etc/completions/x.py.zsh b/src/etc/completions/x.py.zsh
index 89959701a06..1e5a7b5aa89 100644
--- a/src/etc/completions/x.py.zsh
+++ b/src/etc/completions/x.py.zsh
@@ -48,6 +48,7 @@ _x.py() {
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help]' \
 '--help[Print help]' \
 '::paths -- paths for the subcommand:_files' \
@@ -96,6 +97,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -137,6 +139,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -182,6 +185,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -222,6 +226,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -263,6 +268,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -305,6 +311,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -358,6 +365,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -399,6 +407,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help]' \
 '--help[Print help]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -440,6 +449,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help]' \
 '--help[Print help]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -480,6 +490,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help]' \
 '--help[Print help]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -520,6 +531,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help]' \
 '--help[Print help]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -561,6 +573,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
@@ -601,6 +614,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '::profile -- Either the profile for `config.toml` or another setup action. May be omitted to set up interactively:_files' \
@@ -643,6 +657,7 @@ _arguments "${_arguments_options[@]}" \
 '--json-output[use message-format=json]' \
 '--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
 '--enable-bolt-settings[Enable BOLT link flags]' \
+'--skip-stage0-validation[Skip stage0 compiler validation]' \
 '-h[Print help (see more with '\''--help'\'')]' \
 '--help[Print help (see more with '\''--help'\'')]' \
 '*::paths -- paths for the subcommand:_files' \
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index f2447b877ca..4d4c102e69e 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -498,7 +498,7 @@ fn clean_generic_param_def<'tcx>(
 ) -> GenericParamDef {
     let (name, kind) = match def.kind {
         ty::GenericParamDefKind::Lifetime => {
-            (def.name, GenericParamDefKind::Lifetime { outlives: vec![] })
+            (def.name, GenericParamDefKind::Lifetime { outlives: ThinVec::new() })
         }
         ty::GenericParamDefKind::Type { has_default, synthetic, .. } => {
             let default = if has_default {
@@ -515,7 +515,7 @@ fn clean_generic_param_def<'tcx>(
                 def.name,
                 GenericParamDefKind::Type {
                     did: def.def_id,
-                    bounds: vec![], // These are filled in from the where-clauses.
+                    bounds: ThinVec::new(), // These are filled in from the where-clauses.
                     default: default.map(Box::new),
                     synthetic,
                 },
@@ -567,7 +567,7 @@ fn clean_generic_param<'tcx>(
                     })
                     .collect()
             } else {
-                Vec::new()
+                ThinVec::new()
             };
             (param.name.ident().name, GenericParamDefKind::Lifetime { outlives })
         }
@@ -580,7 +580,7 @@ fn clean_generic_param<'tcx>(
                     .filter_map(|x| clean_generic_bound(x, cx))
                     .collect()
             } else {
-                Vec::new()
+                ThinVec::new()
             };
             (
                 param.name.ident().name,
@@ -636,7 +636,7 @@ pub(crate) fn clean_generics<'tcx>(
             match param.kind {
                 GenericParamDefKind::Lifetime { .. } => unreachable!(),
                 GenericParamDefKind::Type { did, ref bounds, .. } => {
-                    cx.impl_trait_bounds.insert(did.into(), bounds.clone());
+                    cx.impl_trait_bounds.insert(did.into(), bounds.to_vec());
                 }
                 GenericParamDefKind::Const { .. } => unreachable!(),
             }
@@ -3146,7 +3146,7 @@ fn clean_bound_vars<'tcx>(
                 name,
                 kind: GenericParamDefKind::Type {
                     did,
-                    bounds: Vec::new(),
+                    bounds: ThinVec::new(),
                     default: None,
                     synthetic: false,
                 },
diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs
index eea8c1906c5..627f15e67ac 100644
--- a/src/librustdoc/clean/simplify.rs
+++ b/src/librustdoc/clean/simplify.rs
@@ -145,7 +145,7 @@ pub(crate) fn move_bounds_to_generic_parameters(generics: &mut clean::Generics)
                 ..
             }) = generics.params.iter_mut().find(|param| &param.name == arg)
         {
-            param_bounds.append(bounds);
+            param_bounds.extend(bounds.drain(..));
         } else if let WherePredicate::RegionPredicate { lifetime: Lifetime(arg), bounds } = &mut pred
             && let Some(GenericParamDef {
                 kind: GenericParamDefKind::Lifetime { outlives: param_bounds },
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 449aac4cfc8..455228d04ef 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -1325,8 +1325,8 @@ impl WherePredicate {
 
 #[derive(Clone, PartialEq, Eq, Debug, Hash)]
 pub(crate) enum GenericParamDefKind {
-    Lifetime { outlives: Vec<Lifetime> },
-    Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
+    Lifetime { outlives: ThinVec<Lifetime> },
+    Type { did: DefId, bounds: ThinVec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
     Const { ty: Box<Type>, default: Option<Box<String>>, is_host_effect: bool },
 }
 
@@ -1344,7 +1344,7 @@ pub(crate) struct GenericParamDef {
 
 impl GenericParamDef {
     pub(crate) fn lifetime(name: Symbol) -> Self {
-        Self { name, kind: GenericParamDefKind::Lifetime { outlives: Vec::new() } }
+        Self { name, kind: GenericParamDefKind::Lifetime { outlives: ThinVec::new() } }
     }
 
     pub(crate) fn is_synthetic_param(&self) -> bool {
@@ -2521,7 +2521,7 @@ mod size_asserts {
     static_assert_size!(DocFragment, 32);
     static_assert_size!(GenericArg, 32);
     static_assert_size!(GenericArgs, 32);
-    static_assert_size!(GenericParamDef, 56);
+    static_assert_size!(GenericParamDef, 40);
     static_assert_size!(Generics, 16);
     static_assert_size!(Item, 56);
     static_assert_size!(ItemKind, 56);
diff --git a/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs b/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs
index d10f10ef87e..7dff37a2b8f 100644
--- a/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs
+++ b/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs
@@ -578,7 +578,7 @@ fn ident_difference_expr_with_base_location(
         | (Assign(_, _, _), Assign(_, _, _))
         | (TryBlock(_), TryBlock(_))
         | (Await(_, _), Await(_, _))
-        | (Async(_, _), Async(_, _))
+        | (Gen(_, _, _), Gen(_, _, _))
         | (Block(_, _), Block(_, _))
         | (Closure(_), Closure(_))
         | (Match(_, _), Match(_, _))
diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs
index a78ff02021f..a2c61e07b70 100644
--- a/src/tools/clippy/clippy_utils/src/ast_utils.rs
+++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs
@@ -211,7 +211,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
                 && eq_fn_decl(lf, rf)
                 && eq_expr(le, re)
         },
-        (Async(lc, lb), Async(rc, rb)) => lc == rc && eq_block(lb, rb),
+        (Gen(lc, lb, lk), Gen(rc, rb, rk)) => lc == rc && eq_block(lb, rb) && lk == rk,
         (Range(lf, lt, ll), Range(rf, rt, rl)) => ll == rl && eq_expr_opt(lf, rf) && eq_expr_opt(lt, rt),
         (AddrOf(lbk, lm, le), AddrOf(rbk, rm, re)) => lbk == rbk && lm == rm && eq_expr(le, re),
         (Path(lq, lp), Path(rq, rp)) => both(lq, rq, eq_qself) && eq_path(lp, rp),
diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs
index ae8ee371ffa..836f8cc1916 100644
--- a/src/tools/clippy/clippy_utils/src/sugg.rs
+++ b/src/tools/clippy/clippy_utils/src/sugg.rs
@@ -190,7 +190,7 @@ impl<'a> Sugg<'a> {
                 (snip, false) => Sugg::MaybeParen(snip),
                 (snip, true) => Sugg::NonParen(snip),
             },
-            ast::ExprKind::Async(..)
+            ast::ExprKind::Gen(..)
             | ast::ExprKind::Block(..)
             | ast::ExprKind::Break(..)
             | ast::ExprKind::Call(..)
diff --git a/src/tools/miri/tests/pass/function_pointers.rs b/src/tools/miri/tests/pass/function_pointers.rs
index 1c99a96feda..36679b7180a 100644
--- a/src/tools/miri/tests/pass/function_pointers.rs
+++ b/src/tools/miri/tests/pass/function_pointers.rs
@@ -80,9 +80,8 @@ fn main() {
     // but Miri currently uses a fixed address for monomorphic functions.
     assert!(return_fn_ptr(i) == i);
     assert!(return_fn_ptr(i) as unsafe fn() -> i32 == i as fn() -> i32 as unsafe fn() -> i32);
-    // We don't check anything for `f`. Miri gives it many different addresses
-    // but mir-opts can turn them into the same address.
-    let _val = return_fn_ptr(f) != f;
+    // Miri gives different addresses to different reifications of a generic function.
+    assert!(return_fn_ptr(f) != f);
     // However, if we only turn `f` into a function pointer and use that pointer,
     // it is equal to itself.
     let f2 = f as fn() -> i32;
diff --git a/src/tools/rustfmt/src/closures.rs b/src/tools/rustfmt/src/closures.rs
index a09146e9592..16b8ce7a916 100644
--- a/src/tools/rustfmt/src/closures.rs
+++ b/src/tools/rustfmt/src/closures.rs
@@ -188,7 +188,7 @@ fn rewrite_closure_expr(
     fn allow_multi_line(expr: &ast::Expr) -> bool {
         match expr.kind {
             ast::ExprKind::Match(..)
-            | ast::ExprKind::Async(..)
+            | ast::ExprKind::Gen(..)
             | ast::ExprKind::Block(..)
             | ast::ExprKind::TryBlock(..)
             | ast::ExprKind::Loop(..)
diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs
index acde8809329..8c2262fde81 100644
--- a/src/tools/rustfmt/src/expr.rs
+++ b/src/tools/rustfmt/src/expr.rs
@@ -367,7 +367,7 @@ pub(crate) fn format_expr(
                 ))
             }
         }
-        ast::ExprKind::Async(capture_by, ref block) => {
+        ast::ExprKind::Gen(capture_by, ref block, ref kind) => {
             let mover = if capture_by == ast::CaptureBy::Value {
                 "move "
             } else {
@@ -375,7 +375,7 @@ pub(crate) fn format_expr(
             };
             if let rw @ Some(_) = rewrite_single_line_block(
                 context,
-                format!("async {mover}").as_str(),
+                format!("{kind} {mover}").as_str(),
                 block,
                 Some(&expr.attrs),
                 None,
@@ -386,7 +386,7 @@ pub(crate) fn format_expr(
                 // 6 = `async `
                 let budget = shape.width.saturating_sub(6);
                 Some(format!(
-                    "async {mover}{}",
+                    "{kind} {mover}{}",
                     rewrite_block(
                         block,
                         Some(&expr.attrs),
@@ -1371,7 +1371,7 @@ pub(crate) fn can_be_overflowed_expr(
         }
 
         // Handle always block-like expressions
-        ast::ExprKind::Async(..) | ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => true,
+        ast::ExprKind::Gen(..) | ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => true,
 
         // Handle `[]` and `{}`-like expressions
         ast::ExprKind::Array(..) | ast::ExprKind::Struct(..) => {
diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs
index 79a759d68ce..fd49030bf1b 100644
--- a/src/tools/rustfmt/src/utils.rs
+++ b/src/tools/rustfmt/src/utils.rs
@@ -473,7 +473,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
         | ast::ExprKind::If(..)
         | ast::ExprKind::Block(..)
         | ast::ExprKind::ConstBlock(..)
-        | ast::ExprKind::Async(..)
+        | ast::ExprKind::Gen(..)
         | ast::ExprKind::Loop(..)
         | ast::ExprKind::ForLoop(..)
         | ast::ExprKind::TryBlock(..)
diff --git a/src/tools/tidy/src/alphabetical.rs b/src/tools/tidy/src/alphabetical.rs
index 3e60915c224..150a9594350 100644
--- a/src/tools/tidy/src/alphabetical.rs
+++ b/src/tools/tidy/src/alphabetical.rs
@@ -1,6 +1,6 @@
 //! Checks that a list of items is in alphabetical order
 //!
-//! To use, use the following annotation in the code:
+//! Use the following marker in the code:
 //! ```rust
 //! // tidy-alphabetical-start
 //! fn aaa() {}
@@ -10,17 +10,23 @@
 //! ```
 //!
 //! The following lines are ignored:
+//! - Empty lines
 //! - Lines that are indented with more or less spaces than the first line
-//! - Lines starting with `//`, `#[`, `)`, `]`, `}` if the comment has the same indentation as
-//!   the first line
+//! - Lines starting with `//`, `#` (except those starting with `#!`), `)`, `]`, `}` if the comment
+//!   has the same indentation as the first line
+//! - Lines starting with a closing delimiter (`)`, `[`, `}`) are ignored.
 //!
-//! If a line ends with an opening bracket, the line is ignored and the next line will have
-//! its extra indentation ignored.
+//! If a line ends with an opening delimiter, we effectively join the following line to it before
+//! checking it. E.g. `foo(\nbar)` is treated like `foo(bar)`.
 
-use std::{fmt::Display, path::Path};
+use std::fmt::Display;
+use std::path::Path;
 
 use crate::walk::{filter_dirs, walk};
 
+#[cfg(test)]
+mod tests;
+
 fn indentation(line: &str) -> usize {
     line.find(|c| c != ' ').unwrap_or(0)
 }
@@ -29,28 +35,36 @@ fn is_close_bracket(c: char) -> bool {
     matches!(c, ')' | ']' | '}')
 }
 
-// Don't let tidy check this here :D
-const START_COMMENT: &str = concat!("tidy-alphabetical", "-start");
-const END_COMMENT: &str = "tidy-alphabetical-end";
+const START_MARKER: &str = "tidy-alphabetical-start";
+const END_MARKER: &str = "tidy-alphabetical-end";
 
 fn check_section<'a>(
     file: impl Display,
     lines: impl Iterator<Item = (usize, &'a str)>,
+    err: &mut dyn FnMut(&str) -> std::io::Result<()>,
     bad: &mut bool,
 ) {
-    let content_lines = lines.take_while(|(_, line)| !line.contains(END_COMMENT));
-
     let mut prev_line = String::new();
     let mut first_indent = None;
     let mut in_split_line = None;
 
-    for (line_idx, line) in content_lines {
-        if line.contains(START_COMMENT) {
-            tidy_error!(
+    for (idx, line) in lines {
+        if line.is_empty() {
+            continue;
+        }
+
+        if line.contains(START_MARKER) {
+            tidy_error_ext!(
+                err,
                 bad,
-                "{file}:{} found `{START_COMMENT}` expecting `{END_COMMENT}`",
-                line_idx
-            )
+                "{file}:{} found `{START_MARKER}` expecting `{END_MARKER}`",
+                idx + 1
+            );
+            return;
+        }
+
+        if line.contains(END_MARKER) {
+            return;
         }
 
         let indent = first_indent.unwrap_or_else(|| {
@@ -60,6 +74,7 @@ fn check_section<'a>(
         });
 
         let line = if let Some(prev_split_line) = in_split_line {
+            // Join the split lines.
             in_split_line = None;
             format!("{prev_split_line}{}", line.trim_start())
         } else {
@@ -73,7 +88,7 @@ fn check_section<'a>(
         let trimmed_line = line.trim_start_matches(' ');
 
         if trimmed_line.starts_with("//")
-            || trimmed_line.starts_with("#[")
+            || (trimmed_line.starts_with("#") && !trimmed_line.starts_with("#!"))
             || trimmed_line.starts_with(is_close_bracket)
         {
             continue;
@@ -87,25 +102,44 @@ fn check_section<'a>(
         let prev_line_trimmed_lowercase = prev_line.trim_start_matches(' ').to_lowercase();
 
         if trimmed_line.to_lowercase() < prev_line_trimmed_lowercase {
-            tidy_error!(bad, "{file}:{}: line not in alphabetical order", line_idx + 1,);
+            tidy_error_ext!(err, bad, "{file}:{}: line not in alphabetical order", idx + 1);
         }
 
         prev_line = line;
     }
+
+    tidy_error_ext!(err, bad, "{file}: reached end of file expecting `{END_MARKER}`")
 }
 
-pub fn check(path: &Path, bad: &mut bool) {
-    walk(path, |path, _is_dir| filter_dirs(path), &mut |entry, contents| {
-        let file = &entry.path().display();
+fn check_lines<'a>(
+    file: &impl Display,
+    mut lines: impl Iterator<Item = (usize, &'a str)>,
+    err: &mut dyn FnMut(&str) -> std::io::Result<()>,
+    bad: &mut bool,
+) {
+    while let Some((idx, line)) = lines.next() {
+        if line.contains(END_MARKER) {
+            tidy_error_ext!(
+                err,
+                bad,
+                "{file}:{} found `{END_MARKER}` expecting `{START_MARKER}`",
+                idx + 1
+            )
+        }
 
-        let mut lines = contents.lines().enumerate().peekable();
-        while let Some((_, line)) = lines.next() {
-            if line.contains(START_COMMENT) {
-                check_section(file, &mut lines, bad);
-                if lines.peek().is_none() {
-                    tidy_error!(bad, "{file}: reached end of file expecting `{END_COMMENT}`")
-                }
-            }
+        if line.contains(START_MARKER) {
+            check_section(file, &mut lines, err, bad);
         }
+    }
+}
+
+pub fn check(path: &Path, bad: &mut bool) {
+    let skip =
+        |path: &_, _is_dir| filter_dirs(path) || path.ends_with("tidy/src/alphabetical/tests.rs");
+
+    walk(path, skip, &mut |entry, contents| {
+        let file = &entry.path().display();
+        let lines = contents.lines().enumerate();
+        check_lines(file, lines, &mut crate::tidy_error, bad)
     });
 }
diff --git a/src/tools/tidy/src/alphabetical/tests.rs b/src/tools/tidy/src/alphabetical/tests.rs
new file mode 100644
index 00000000000..560e0284b89
--- /dev/null
+++ b/src/tools/tidy/src/alphabetical/tests.rs
@@ -0,0 +1,188 @@
+use super::*;
+use std::io::Write;
+use std::str::from_utf8;
+
+fn test(lines: &str, name: &str, expected_msg: &str, expected_bad: bool) {
+    let mut actual_msg = Vec::new();
+    let mut actual_bad = false;
+    let mut err = |args: &_| {
+        write!(&mut actual_msg, "{args}")?;
+        Ok(())
+    };
+    check_lines(&name, lines.lines().enumerate(), &mut err, &mut actual_bad);
+    assert_eq!(expected_msg, from_utf8(&actual_msg).unwrap());
+    assert_eq!(expected_bad, actual_bad);
+}
+
+fn good(lines: &str) {
+    test(lines, "good", "", false);
+}
+
+fn bad(lines: &str, expected_msg: &str) {
+    test(lines, "bad", expected_msg, true);
+}
+
+#[test]
+fn test_no_markers() {
+    let lines = "\
+        def
+        abc
+        xyz
+    ";
+    good(lines);
+}
+
+#[test]
+fn test_rust_good() {
+    let lines = "\
+        // tidy-alphabetical-start
+        abc
+        def
+        xyz
+        // tidy-alphabetical-end"; // important: end marker on last line
+    good(lines);
+}
+
+#[test]
+fn test_complex_good() {
+    let lines = "\
+        zzz
+
+        // tidy-alphabetical-start
+        abc
+        // Rust comments are ok
+        def
+        # TOML comments are ok
+        xyz
+        // tidy-alphabetical-end
+
+        # tidy-alphabetical-start
+        foo(abc);
+        // blank lines are ok
+
+        // split line gets joined
+        foo(
+            def
+        );
+
+        foo(xyz);
+        # tidy-alphabetical-end
+
+        % tidy-alphabetical-start
+        abc
+            ignored_due_to_different_indent
+        def
+        % tidy-alphabetical-end
+
+        aaa
+    ";
+    good(lines);
+}
+
+#[test]
+fn test_rust_bad() {
+    let lines = "\
+        // tidy-alphabetical-start
+        abc
+        xyz
+        def
+        // tidy-alphabetical-end
+    ";
+    bad(lines, "bad:4: line not in alphabetical order");
+}
+
+#[test]
+fn test_toml_bad() {
+    let lines = "\
+        # tidy-alphabetical-start
+        abc
+        xyz
+        def
+        # tidy-alphabetical-end
+    ";
+    bad(lines, "bad:4: line not in alphabetical order");
+}
+
+#[test]
+fn test_features_bad() {
+    // Even though lines starting with `#` are treated as comments, lines
+    // starting with `#!` are an exception.
+    let lines = "\
+        tidy-alphabetical-start
+        #![feature(abc)]
+        #![feature(xyz)]
+        #![feature(def)]
+        tidy-alphabetical-end
+    ";
+    bad(lines, "bad:4: line not in alphabetical order");
+}
+
+#[test]
+fn test_indent_bad() {
+    // All lines are indented the same amount, and so are checked.
+    let lines = "\
+        $ tidy-alphabetical-start
+            abc
+            xyz
+            def
+        $ tidy-alphabetical-end
+    ";
+    bad(lines, "bad:4: line not in alphabetical order");
+}
+
+#[test]
+fn test_split_bad() {
+    let lines = "\
+        || tidy-alphabetical-start
+        foo(abc)
+        foo(
+            xyz
+        )
+        foo(
+            def
+        )
+        && tidy-alphabetical-end
+    ";
+    bad(lines, "bad:7: line not in alphabetical order");
+}
+
+#[test]
+fn test_double_start() {
+    let lines = "\
+        tidy-alphabetical-start
+        abc
+        tidy-alphabetical-start
+    ";
+    bad(lines, "bad:3 found `tidy-alphabetical-start` expecting `tidy-alphabetical-end`");
+}
+
+#[test]
+fn test_missing_start() {
+    let lines = "\
+        abc
+        tidy-alphabetical-end
+        abc
+    ";
+    bad(lines, "bad:2 found `tidy-alphabetical-end` expecting `tidy-alphabetical-start`");
+}
+
+#[test]
+fn test_missing_end() {
+    let lines = "\
+        tidy-alphabetical-start
+        abc
+    ";
+    bad(lines, "bad: reached end of file expecting `tidy-alphabetical-end`");
+}
+
+#[test]
+fn test_double_end() {
+    let lines = "\
+        tidy-alphabetical-start
+        abc
+        tidy-alphabetical-end
+        def
+        tidy-alphabetical-end
+    ";
+    bad(lines, "bad:5 found `tidy-alphabetical-end` expecting `tidy-alphabetical-start`");
+}
diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs
index fc69c143222..eb0a2fda290 100644
--- a/src/tools/tidy/src/lib.rs
+++ b/src/tools/tidy/src/lib.rs
@@ -3,8 +3,6 @@
 //! This library contains the tidy lints and exposes it
 //! to be used by tools.
 
-use std::fmt::Display;
-
 use termcolor::WriteColor;
 
 /// A helper macro to `unwrap` a result except also print out details like:
@@ -31,16 +29,22 @@ macro_rules! t {
 
 macro_rules! tidy_error {
     ($bad:expr, $($fmt:tt)*) => ({
-        $crate::tidy_error($bad, format_args!($($fmt)*)).expect("failed to output error");
+        $crate::tidy_error(&format_args!($($fmt)*).to_string()).expect("failed to output error");
+        *$bad = true;
     });
 }
 
-fn tidy_error(bad: &mut bool, args: impl Display) -> std::io::Result<()> {
+macro_rules! tidy_error_ext {
+    ($tidy_error:path, $bad:expr, $($fmt:tt)*) => ({
+        $tidy_error(&format_args!($($fmt)*).to_string()).expect("failed to output error");
+        *$bad = true;
+    });
+}
+
+fn tidy_error(args: &str) -> std::io::Result<()> {
     use std::io::Write;
     use termcolor::{Color, ColorChoice, ColorSpec, StandardStream};
 
-    *bad = true;
-
     let mut stderr = StandardStream::stdout(ColorChoice::Auto);
     stderr.set_color(ColorSpec::new().set_fg(Some(Color::Red)))?;
 
diff --git a/tests/assembly/closure-inherit-target-feature.rs b/tests/assembly/closure-inherit-target-feature.rs
index 24802603452..7acda76e25f 100644
--- a/tests/assembly/closure-inherit-target-feature.rs
+++ b/tests/assembly/closure-inherit-target-feature.rs
@@ -1,4 +1,5 @@
 // only-x86_64
+// ignore-sgx Tests incompatible with LVI mitigations
 // assembly-output: emit-asm
 // make sure the feature is not enabled at compile-time
 // compile-flags: -C opt-level=3 -C target-feature=-sse4.1 -C llvm-args=-x86-asm-syntax=intel
diff --git a/tests/coverage-map/fn_sig_into_try.cov-map b/tests/coverage-map/fn_sig_into_try.cov-map
index 4672e7c1ce9..6e26c61aac9 100644
--- a/tests/coverage-map/fn_sig_into_try.cov-map
+++ b/tests/coverage-map/fn_sig_into_try.cov-map
@@ -7,47 +7,47 @@ Number of file 0 mappings: 1
 - Code(Counter(0)) at (prev + 10, 1) to (start + 4, 2)
 
 Function name: fn_sig_into_try::b
-Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 10, 01, 02, 0f, 00, 02, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
+Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 10, 01, 02, 0f, 00, 02, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 2
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 16, 1) to (start + 2, 15)
 - Code(Zero) at (prev + 2, 15) to (start + 0, 16)
 - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
-    = (c0 - c1)
+    = (c0 - Zero)
 - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
-    = (c1 + (c0 - c1))
+    = (Zero + (c0 - Zero))
 
 Function name: fn_sig_into_try::c
-Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 16, 01, 02, 17, 00, 02, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
+Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 16, 01, 02, 17, 00, 02, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 2
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 22, 1) to (start + 2, 23)
 - Code(Zero) at (prev + 2, 23) to (start + 0, 24)
 - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
-    = (c0 - c1)
+    = (c0 - Zero)
 - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
-    = (c1 + (c0 - c1))
+    = (Zero + (c0 - Zero))
 
 Function name: fn_sig_into_try::d
-Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 1c, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
+Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 1c, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 2
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 28, 1) to (start + 3, 15)
 - Code(Zero) at (prev + 3, 15) to (start + 0, 16)
 - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
-    = (c0 - c1)
+    = (c0 - Zero)
 - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
-    = (c1 + (c0 - c1))
+    = (Zero + (c0 - Zero))
 
diff --git a/tests/coverage-map/status-quo/bad_counter_ids.cov-map b/tests/coverage-map/status-quo/bad_counter_ids.cov-map
new file mode 100644
index 00000000000..0b8081acfa6
--- /dev/null
+++ b/tests/coverage-map/status-quo/bad_counter_ids.cov-map
@@ -0,0 +1,98 @@
+Function name: <bad_counter_ids::Foo as core::cmp::PartialEq>::eq
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 11, 00, 1a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 12, 17) to (start + 0, 26)
+
+Function name: <bad_counter_ids::Foo as core::fmt::Debug>::fmt
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 0a, 00, 0f]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 12, 10) to (start + 0, 15)
+
+Function name: bad_counter_ids::eq_bad
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 23, 01, 02, 1f, 00, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 35, 1) to (start + 2, 31)
+- Code(Zero) at (prev + 3, 1) to (start + 0, 2)
+
+Function name: bad_counter_ids::eq_bad_message
+Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 28, 01, 02, 0f, 02, 02, 20, 00, 2b, 00, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 40, 1) to (start + 2, 15)
+- Code(Expression(0, Sub)) at (prev + 2, 32) to (start + 0, 43)
+    = (c0 - Zero)
+- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
+
+Function name: bad_counter_ids::eq_good
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 0f, 01, 02, 1f, 05, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 15, 1) to (start + 2, 31)
+- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2)
+
+Function name: bad_counter_ids::eq_good_message
+Raw bytes (19): 0x[01, 01, 00, 03, 01, 14, 01, 02, 0f, 00, 02, 20, 00, 2b, 05, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 20, 1) to (start + 2, 15)
+- Code(Zero) at (prev + 2, 32) to (start + 0, 43)
+- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
+
+Function name: bad_counter_ids::ne_bad
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 2d, 01, 02, 1f, 00, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 45, 1) to (start + 2, 31)
+- Code(Zero) at (prev + 3, 1) to (start + 0, 2)
+
+Function name: bad_counter_ids::ne_bad_message
+Raw bytes (19): 0x[01, 01, 00, 03, 01, 32, 01, 02, 0f, 05, 02, 20, 00, 2b, 00, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 50, 1) to (start + 2, 15)
+- Code(Counter(1)) at (prev + 2, 32) to (start + 0, 43)
+- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
+
+Function name: bad_counter_ids::ne_good
+Raw bytes (16): 0x[01, 01, 01, 01, 00, 02, 01, 19, 01, 02, 1f, 02, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 25, 1) to (start + 2, 31)
+- Code(Expression(0, Sub)) at (prev + 3, 1) to (start + 0, 2)
+    = (c0 - Zero)
+
+Function name: bad_counter_ids::ne_good_message
+Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 1e, 01, 02, 0f, 00, 02, 20, 00, 2b, 02, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 30, 1) to (start + 2, 15)
+- Code(Zero) at (prev + 2, 32) to (start + 0, 43)
+- Code(Expression(0, Sub)) at (prev + 1, 1) to (start + 0, 2)
+    = (c0 - Zero)
+
diff --git a/tests/coverage-map/status-quo/bad_counter_ids.rs b/tests/coverage-map/status-quo/bad_counter_ids.rs
new file mode 100644
index 00000000000..ef5460102b7
--- /dev/null
+++ b/tests/coverage-map/status-quo/bad_counter_ids.rs
@@ -0,0 +1,66 @@
+#![feature(coverage_attribute)]
+// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3
+
+// Regression test for <https://github.com/rust-lang/rust/issues/117012>.
+//
+// If some coverage counters were removed by MIR optimizations, we need to take
+// care not to refer to those counter IDs in coverage mappings, and instead
+// replace them with a constant zero value. If we don't, `llvm-cov` might see
+// a too-large counter ID and silently discard the entire function from its
+// coverage reports.
+
+#[derive(Debug, PartialEq, Eq)]
+struct Foo(u32);
+
+fn eq_good() {
+    println!("a");
+    assert_eq!(Foo(1), Foo(1));
+}
+
+fn eq_good_message() {
+    println!("b");
+    assert_eq!(Foo(1), Foo(1), "message b");
+}
+
+fn ne_good() {
+    println!("c");
+    assert_ne!(Foo(1), Foo(3));
+}
+
+fn ne_good_message() {
+    println!("d");
+    assert_ne!(Foo(1), Foo(3), "message d");
+}
+
+fn eq_bad() {
+    println!("e");
+    assert_eq!(Foo(1), Foo(3));
+}
+
+fn eq_bad_message() {
+    println!("f");
+    assert_eq!(Foo(1), Foo(3), "message f");
+}
+
+fn ne_bad() {
+    println!("g");
+    assert_ne!(Foo(1), Foo(1));
+}
+
+fn ne_bad_message() {
+    println!("h");
+    assert_ne!(Foo(1), Foo(1), "message h");
+}
+
+#[coverage(off)]
+fn main() {
+    eq_good();
+    eq_good_message();
+    ne_good();
+    ne_good_message();
+
+    assert!(std::panic::catch_unwind(eq_bad).is_err());
+    assert!(std::panic::catch_unwind(eq_bad_message).is_err());
+    assert!(std::panic::catch_unwind(ne_bad).is_err());
+    assert!(std::panic::catch_unwind(ne_bad_message).is_err());
+}
diff --git a/tests/coverage-map/status-quo/inline-dead.cov-map b/tests/coverage-map/status-quo/inline-dead.cov-map
index 06b64da5723..958b423f24c 100644
--- a/tests/coverage-map/status-quo/inline-dead.cov-map
+++ b/tests/coverage-map/status-quo/inline-dead.cov-map
@@ -7,19 +7,19 @@ Number of file 0 mappings: 1
 - Code(Zero) at (prev + 25, 1) to (start + 2, 2)
 
 Function name: inline_dead::live::<false>
-Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 10, 01, 01, 09, 00, 02, 09, 00, 0f, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02]
+Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 10, 01, 01, 09, 00, 02, 09, 00, 0f, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 2
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 16, 1) to (start + 1, 9)
 - Code(Zero) at (prev + 2, 9) to (start + 0, 15)
 - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10)
-    = (c0 - c1)
+    = (c0 - Zero)
 - Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2)
-    = (c1 + (c0 - c1))
+    = (Zero + (c0 - Zero))
 
 Function name: inline_dead::main
 Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 01, 03, 0d, 01, 07, 06, 02, 02]
@@ -31,15 +31,15 @@ Number of file 0 mappings: 2
 - Code(Counter(0)) at (prev + 7, 6) to (start + 2, 2)
 
 Function name: inline_dead::main::{closure#0}
-Raw bytes (23): 0x[01, 01, 02, 09, 06, 01, 05, 03, 01, 07, 17, 00, 18, 00, 02, 0d, 00, 0e, 03, 02, 05, 00, 06]
+Raw bytes (23): 0x[01, 01, 02, 00, 06, 01, 00, 03, 01, 07, 17, 00, 18, 00, 02, 0d, 00, 0e, 03, 02, 05, 00, 06]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 2
-- expression 0 operands: lhs = Counter(2), rhs = Expression(1, Sub)
-- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 0 operands: lhs = Zero, rhs = Expression(1, Sub)
+- expression 1 operands: lhs = Counter(0), rhs = Zero
 Number of file 0 mappings: 3
 - Code(Counter(0)) at (prev + 7, 23) to (start + 0, 24)
 - Code(Zero) at (prev + 2, 13) to (start + 0, 14)
 - Code(Expression(0, Add)) at (prev + 2, 5) to (start + 0, 6)
-    = (c2 + (c0 - c1))
+    = (Zero + (c0 - Zero))
 
diff --git a/tests/coverage-map/status-quo/issue-84561.cov-map b/tests/coverage-map/status-quo/issue-84561.cov-map
index 76340b1a78c..82582b309bf 100644
--- a/tests/coverage-map/status-quo/issue-84561.cov-map
+++ b/tests/coverage-map/status-quo/issue-84561.cov-map
@@ -85,47 +85,47 @@ Number of file 0 mappings: 1
 - Code(Counter(0)) at (prev + 165, 9) to (start + 2, 10)
 
 Function name: issue_84561::test3
-Raw bytes (437): 0x[01, 01, 41, 05, 09, 0d, 11, 15, 19, 12, 1d, 15, 19, 21, 25, 1e, 29, 21, 25, 31, 39, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 4d, 3f, 51, 42, 49, 45, 4d, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 92, 01, 55, 51, 59, 8f, 01, 5d, 92, 01, 55, 51, 59, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 71, fe, 01, 82, 02, 71, 69, 6d, 69, 6d, 82, 02, 71, 69, 6d, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, ee, 01, 81, 01, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 33, 01, 06, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 71, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02]
+Raw bytes (436): 0x[01, 01, 41, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 92, 01, 55, 51, 00, 8f, 01, 5d, 92, 01, 55, 51, 00, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 71, fe, 01, 82, 02, 71, 69, 6d, 69, 6d, 82, 02, 71, 69, 6d, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, ee, 01, 00, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 33, 01, 06, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 71, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 65
 - expression 0 operands: lhs = Counter(1), rhs = Counter(2)
-- expression 1 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 1 operands: lhs = Counter(3), rhs = Zero
 - expression 2 operands: lhs = Counter(5), rhs = Counter(6)
-- expression 3 operands: lhs = Expression(4, Sub), rhs = Counter(7)
+- expression 3 operands: lhs = Expression(4, Sub), rhs = Zero
 - expression 4 operands: lhs = Counter(5), rhs = Counter(6)
-- expression 5 operands: lhs = Counter(8), rhs = Counter(9)
-- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(10)
-- expression 7 operands: lhs = Counter(8), rhs = Counter(9)
-- expression 8 operands: lhs = Counter(12), rhs = Counter(14)
+- expression 5 operands: lhs = Counter(8), rhs = Zero
+- expression 6 operands: lhs = Expression(7, Sub), rhs = Zero
+- expression 7 operands: lhs = Counter(8), rhs = Zero
+- expression 8 operands: lhs = Counter(12), rhs = Zero
 - expression 9 operands: lhs = Counter(15), rhs = Counter(16)
 - expression 10 operands: lhs = Expression(11, Sub), rhs = Counter(17)
 - expression 11 operands: lhs = Counter(15), rhs = Counter(16)
 - expression 12 operands: lhs = Expression(16, Sub), rhs = Counter(18)
-- expression 13 operands: lhs = Counter(17), rhs = Counter(19)
+- expression 13 operands: lhs = Counter(17), rhs = Zero
 - expression 14 operands: lhs = Expression(15, Add), rhs = Counter(20)
 - expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(18)
-- expression 16 operands: lhs = Counter(17), rhs = Counter(19)
+- expression 16 operands: lhs = Counter(17), rhs = Zero
 - expression 17 operands: lhs = Counter(23), rhs = Expression(34, Sub)
 - expression 18 operands: lhs = Expression(35, Add), rhs = Counter(23)
 - expression 19 operands: lhs = Expression(36, Sub), rhs = Counter(21)
-- expression 20 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 20 operands: lhs = Counter(20), rhs = Zero
 - expression 21 operands: lhs = Expression(36, Sub), rhs = Counter(21)
-- expression 22 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 22 operands: lhs = Counter(20), rhs = Zero
 - expression 23 operands: lhs = Expression(35, Add), rhs = Counter(23)
 - expression 24 operands: lhs = Expression(36, Sub), rhs = Counter(21)
-- expression 25 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 25 operands: lhs = Counter(20), rhs = Zero
 - expression 26 operands: lhs = Expression(33, Add), rhs = Counter(24)
 - expression 27 operands: lhs = Counter(23), rhs = Expression(34, Sub)
 - expression 28 operands: lhs = Expression(35, Add), rhs = Counter(23)
 - expression 29 operands: lhs = Expression(36, Sub), rhs = Counter(21)
-- expression 30 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 30 operands: lhs = Counter(20), rhs = Zero
 - expression 31 operands: lhs = Expression(32, Sub), rhs = Counter(25)
 - expression 32 operands: lhs = Expression(33, Add), rhs = Counter(24)
 - expression 33 operands: lhs = Counter(23), rhs = Expression(34, Sub)
 - expression 34 operands: lhs = Expression(35, Add), rhs = Counter(23)
 - expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(21)
-- expression 36 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 36 operands: lhs = Counter(20), rhs = Zero
 - expression 37 operands: lhs = Counter(29), rhs = Expression(61, Sub)
 - expression 38 operands: lhs = Expression(62, Add), rhs = Counter(30)
 - expression 39 operands: lhs = Counter(28), rhs = Expression(63, Sub)
@@ -147,7 +147,7 @@ Number of expressions: 65
 - expression 55 operands: lhs = Counter(28), rhs = Expression(63, Sub)
 - expression 56 operands: lhs = Expression(64, Sub), rhs = Counter(28)
 - expression 57 operands: lhs = Counter(26), rhs = Counter(27)
-- expression 58 operands: lhs = Expression(59, Sub), rhs = Counter(32)
+- expression 58 operands: lhs = Expression(59, Sub), rhs = Zero
 - expression 59 operands: lhs = Expression(60, Add), rhs = Counter(31)
 - expression 60 operands: lhs = Counter(29), rhs = Expression(61, Sub)
 - expression 61 operands: lhs = Expression(62, Add), rhs = Counter(30)
@@ -161,27 +161,27 @@ Number of file 0 mappings: 51
     = (c1 - c2)
 - Code(Counter(3)) at (prev + 5, 5) to (start + 0, 31)
 - Code(Expression(1, Sub)) at (prev + 1, 5) to (start + 0, 31)
-    = (c3 - c4)
+    = (c3 - Zero)
 - Code(Counter(5)) at (prev + 1, 9) to (start + 1, 28)
 - Code(Expression(4, Sub)) at (prev + 2, 5) to (start + 0, 31)
     = (c5 - c6)
 - Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 15)
-    = ((c5 - c6) - c7)
+    = ((c5 - c6) - Zero)
 - Code(Zero) at (prev + 0, 32) to (start + 0, 48)
 - Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15)
 - Code(Zero) at (prev + 3, 32) to (start + 0, 48)
 - Code(Zero) at (prev + 0, 51) to (start + 0, 65)
 - Code(Zero) at (prev + 0, 75) to (start + 0, 90)
 - Code(Expression(7, Sub)) at (prev + 1, 5) to (start + 0, 15)
-    = (c8 - c9)
+    = (c8 - Zero)
 - Code(Zero) at (prev + 5, 9) to (start + 3, 16)
 - Code(Zero) at (prev + 5, 13) to (start + 0, 27)
 - Code(Zero) at (prev + 2, 13) to (start + 0, 28)
 - Code(Expression(6, Sub)) at (prev + 4, 9) to (start + 5, 6)
-    = ((c8 - c9) - c10)
+    = ((c8 - Zero) - Zero)
 - Code(Counter(12)) at (prev + 6, 5) to (start + 3, 6)
 - Code(Expression(8, Sub)) at (prev + 4, 5) to (start + 3, 6)
-    = (c12 - c14)
+    = (c12 - Zero)
 - Code(Counter(15)) at (prev + 4, 9) to (start + 4, 6)
 - Code(Expression(11, Sub)) at (prev + 5, 8) to (start + 0, 15)
     = (c15 - c16)
@@ -189,24 +189,24 @@ Number of file 0 mappings: 51
 - Code(Expression(10, Sub)) at (prev + 5, 9) to (start + 3, 10)
     = ((c15 - c16) - c17)
 - Code(Expression(15, Add)) at (prev + 5, 8) to (start + 0, 15)
-    = ((c17 - c19) + c18)
+    = ((c17 - Zero) + c18)
 - Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19)
 - Code(Zero) at (prev + 3, 13) to (start + 0, 29)
 - Code(Expression(14, Sub)) at (prev + 3, 9) to (start + 0, 19)
-    = (((c17 - c19) + c18) - c20)
+    = (((c17 - Zero) + c18) - c20)
 - Code(Zero) at (prev + 3, 13) to (start + 0, 29)
 - Code(Expression(33, Add)) at (prev + 3, 5) to (start + 0, 15)
-    = (c23 + (((c20 - c22) + c21) - c23))
+    = (c23 + (((c20 - Zero) + c21) - c23))
 - Code(Expression(35, Add)) at (prev + 1, 12) to (start + 0, 19)
-    = ((c20 - c22) + c21)
+    = ((c20 - Zero) + c21)
 - Code(Counter(23)) at (prev + 1, 13) to (start + 0, 19)
 - Code(Expression(34, Sub)) at (prev + 2, 13) to (start + 0, 19)
-    = (((c20 - c22) + c21) - c23)
+    = (((c20 - Zero) + c21) - c23)
 - Code(Expression(32, Sub)) at (prev + 4, 5) to (start + 2, 19)
-    = ((c23 + (((c20 - c22) + c21) - c23)) - c24)
+    = ((c23 + (((c20 - Zero) + c21) - c23)) - c24)
 - Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19)
 - Code(Expression(31, Sub)) at (prev + 2, 13) to (start + 0, 19)
-    = (((c23 + (((c20 - c22) + c21) - c23)) - c24) - c25)
+    = (((c23 + (((c20 - Zero) + c21) - c23)) - c24) - c25)
 - Code(Expression(60, Add)) at (prev + 3, 5) to (start + 0, 15)
     = (c29 + ((c28 + ((c26 - c27) - c28)) - c30))
 - Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19)
@@ -225,7 +225,7 @@ Number of file 0 mappings: 51
 - Code(Expression(59, Sub)) at (prev + 2, 5) to (start + 0, 15)
     = ((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31)
 - Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 34)
-    = (((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) - c32)
+    = (((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) - Zero)
 - Code(Zero) at (prev + 2, 5) to (start + 0, 15)
 - Code(Zero) at (prev + 3, 9) to (start + 0, 44)
 - Code(Zero) at (prev + 2, 1) to (start + 0, 2)
diff --git a/tests/coverage-map/status-quo/loops_branches.cov-map b/tests/coverage-map/status-quo/loops_branches.cov-map
index ebace8cbd71..813583a9de7 100644
--- a/tests/coverage-map/status-quo/loops_branches.cov-map
+++ b/tests/coverage-map/status-quo/loops_branches.cov-map
@@ -1,177 +1,177 @@
 Function name: <loops_branches::DebugTest as core::fmt::Debug>::fmt
-Raw bytes (249): 0x[01, 01, 31, 05, 09, 00, 02, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, bf, 01, c3, 01, 0d, 00, 11, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, b2, 01, 1d, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, 00, ae, 01, b2, 01, 1d, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, ab, 01, 11, 00, ae, 01, b2, 01, 1d, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, 25, a3, 01, a6, 01, 19, ab, 01, 11, 00, ae, 01, b2, 01, 1d, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0e, 00, 0f, 07, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, b6, 01, 03, 0d, 00, 0e, bb, 01, 00, 12, 00, 17, b6, 01, 01, 10, 00, 14, b2, 01, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, ae, 01, 01, 12, 00, 13, ab, 01, 01, 11, 00, 22, a6, 01, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 19, 03, 09, 00, 0f, 9f, 01, 01, 05, 00, 06]
+Raw bytes (249): 0x[01, 01, 31, 05, 00, 00, 02, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, bf, 01, c3, 01, 0d, 00, 11, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, ab, 01, 11, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, 25, a3, 01, a6, 01, 19, ab, 01, 11, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0e, 00, 0f, 07, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, b6, 01, 03, 0d, 00, 0e, bb, 01, 00, 12, 00, 17, b6, 01, 01, 10, 00, 14, b2, 01, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, ae, 01, 01, 12, 00, 13, ab, 01, 01, 11, 00, 22, a6, 01, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 19, 03, 09, 00, 0f, 9f, 01, 01, 05, 00, 06]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 49
-- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 0 operands: lhs = Counter(1), rhs = Zero
 - expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
 - expression 2 operands: lhs = Expression(46, Add), rhs = Counter(6)
 - expression 3 operands: lhs = Expression(47, Add), rhs = Expression(48, Add)
 - expression 4 operands: lhs = Counter(3), rhs = Zero
-- expression 5 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 5 operands: lhs = Counter(4), rhs = Zero
 - expression 6 operands: lhs = Expression(47, Add), rhs = Expression(48, Add)
 - expression 7 operands: lhs = Counter(3), rhs = Zero
-- expression 8 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 8 operands: lhs = Counter(4), rhs = Zero
 - expression 9 operands: lhs = Expression(46, Add), rhs = Counter(6)
 - expression 10 operands: lhs = Expression(47, Add), rhs = Expression(48, Add)
 - expression 11 operands: lhs = Counter(3), rhs = Zero
-- expression 12 operands: lhs = Counter(4), rhs = Counter(5)
-- expression 13 operands: lhs = Expression(45, Sub), rhs = Counter(5)
+- expression 12 operands: lhs = Counter(4), rhs = Zero
+- expression 13 operands: lhs = Expression(45, Sub), rhs = Zero
 - expression 14 operands: lhs = Expression(46, Add), rhs = Counter(6)
 - expression 15 operands: lhs = Expression(47, Add), rhs = Expression(48, Add)
 - expression 16 operands: lhs = Counter(3), rhs = Zero
-- expression 17 operands: lhs = Counter(4), rhs = Counter(5)
-- expression 18 operands: lhs = Expression(44, Sub), rhs = Counter(7)
-- expression 19 operands: lhs = Expression(45, Sub), rhs = Counter(5)
+- expression 17 operands: lhs = Counter(4), rhs = Zero
+- expression 18 operands: lhs = Expression(44, Sub), rhs = Zero
+- expression 19 operands: lhs = Expression(45, Sub), rhs = Zero
 - expression 20 operands: lhs = Expression(46, Add), rhs = Counter(6)
 - expression 21 operands: lhs = Expression(47, Add), rhs = Expression(48, Add)
 - expression 22 operands: lhs = Counter(3), rhs = Zero
-- expression 23 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 23 operands: lhs = Counter(4), rhs = Zero
 - expression 24 operands: lhs = Zero, rhs = Expression(43, Sub)
-- expression 25 operands: lhs = Expression(44, Sub), rhs = Counter(7)
-- expression 26 operands: lhs = Expression(45, Sub), rhs = Counter(5)
+- expression 25 operands: lhs = Expression(44, Sub), rhs = Zero
+- expression 26 operands: lhs = Expression(45, Sub), rhs = Zero
 - expression 27 operands: lhs = Expression(46, Add), rhs = Counter(6)
 - expression 28 operands: lhs = Expression(47, Add), rhs = Expression(48, Add)
 - expression 29 operands: lhs = Counter(3), rhs = Zero
-- expression 30 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 30 operands: lhs = Counter(4), rhs = Zero
 - expression 31 operands: lhs = Expression(42, Add), rhs = Counter(4)
 - expression 32 operands: lhs = Zero, rhs = Expression(43, Sub)
-- expression 33 operands: lhs = Expression(44, Sub), rhs = Counter(7)
-- expression 34 operands: lhs = Expression(45, Sub), rhs = Counter(5)
+- expression 33 operands: lhs = Expression(44, Sub), rhs = Zero
+- expression 34 operands: lhs = Expression(45, Sub), rhs = Zero
 - expression 35 operands: lhs = Expression(46, Add), rhs = Counter(6)
 - expression 36 operands: lhs = Expression(47, Add), rhs = Expression(48, Add)
 - expression 37 operands: lhs = Counter(3), rhs = Zero
-- expression 38 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 38 operands: lhs = Counter(4), rhs = Zero
 - expression 39 operands: lhs = Counter(9), rhs = Expression(40, Add)
 - expression 40 operands: lhs = Expression(41, Sub), rhs = Counter(6)
 - expression 41 operands: lhs = Expression(42, Add), rhs = Counter(4)
 - expression 42 operands: lhs = Zero, rhs = Expression(43, Sub)
-- expression 43 operands: lhs = Expression(44, Sub), rhs = Counter(7)
-- expression 44 operands: lhs = Expression(45, Sub), rhs = Counter(5)
+- expression 43 operands: lhs = Expression(44, Sub), rhs = Zero
+- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero
 - expression 45 operands: lhs = Expression(46, Add), rhs = Counter(6)
 - expression 46 operands: lhs = Expression(47, Add), rhs = Expression(48, Add)
 - expression 47 operands: lhs = Counter(3), rhs = Zero
-- expression 48 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 48 operands: lhs = Counter(4), rhs = Zero
 Number of file 0 mappings: 20
 - Code(Counter(0)) at (prev + 9, 5) to (start + 1, 16)
 - Code(Counter(1)) at (prev + 2, 16) to (start + 0, 21)
 - Code(Zero) at (prev + 1, 23) to (start + 0, 27)
 - Code(Zero) at (prev + 0, 28) to (start + 0, 30)
 - Code(Expression(0, Sub)) at (prev + 1, 14) to (start + 0, 15)
-    = (c1 - c2)
+    = (c1 - Zero)
 - Code(Expression(1, Add)) at (prev + 1, 13) to (start + 0, 30)
-    = (Zero + (c1 - c2))
+    = (Zero + (c1 - Zero))
 - Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31)
 - Code(Zero) at (prev + 1, 16) to (start + 1, 10)
 - Code(Expression(45, Sub)) at (prev + 3, 13) to (start + 0, 14)
-    = (((c3 + Zero) + (c4 + c5)) - c6)
+    = (((c3 + Zero) + (c4 + Zero)) - c6)
 - Code(Expression(46, Add)) at (prev + 0, 18) to (start + 0, 23)
-    = ((c3 + Zero) + (c4 + c5))
+    = ((c3 + Zero) + (c4 + Zero))
 - Code(Expression(45, Sub)) at (prev + 1, 16) to (start + 0, 20)
-    = (((c3 + Zero) + (c4 + c5)) - c6)
+    = (((c3 + Zero) + (c4 + Zero)) - c6)
 - Code(Expression(44, Sub)) at (prev + 1, 20) to (start + 0, 25)
-    = ((((c3 + Zero) + (c4 + c5)) - c6) - c5)
+    = ((((c3 + Zero) + (c4 + Zero)) - c6) - Zero)
 - Code(Zero) at (prev + 1, 27) to (start + 0, 31)
 - Code(Zero) at (prev + 0, 32) to (start + 0, 34)
 - Code(Expression(43, Sub)) at (prev + 1, 18) to (start + 0, 19)
-    = (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)
+    = (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)
 - Code(Expression(42, Add)) at (prev + 1, 17) to (start + 0, 34)
-    = (Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7))
+    = (Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero))
 - Code(Expression(41, Sub)) at (prev + 0, 34) to (start + 0, 35)
-    = ((Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) - c4)
+    = ((Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)) - c4)
 - Code(Zero) at (prev + 1, 20) to (start + 1, 14)
 - Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15)
 - Code(Expression(39, Add)) at (prev + 1, 5) to (start + 0, 6)
-    = (c9 + (((Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) - c4) + c6))
+    = (c9 + (((Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)) - c4) + c6))
 
 Function name: <loops_branches::DisplayTest as core::fmt::Display>::fmt
-Raw bytes (253): 0x[01, 01, 33, 01, 05, 02, 09, 00, 0e, 02, 09, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, c3, 01, c7, 01, 05, 0d, 11, 15, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, b6, 01, 1d, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, 00, b2, 01, b6, 01, 1d, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, af, 01, 15, 00, b2, 01, b6, 01, 1d, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, aa, 01, cb, 01, af, 01, 15, 00, b2, 01, b6, 01, 1d, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, 19, 25, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 0e, 01, 0e, 00, 0f, 0b, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, ba, 01, 02, 0d, 00, 0e, bf, 01, 00, 12, 00, 17, ba, 01, 01, 10, 00, 15, 00, 00, 16, 01, 0e, b6, 01, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, b2, 01, 01, 12, 00, 13, af, 01, 01, 11, 00, 22, aa, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, a7, 01, 01, 05, 00, 06]
+Raw bytes (253): 0x[01, 01, 33, 01, 00, 02, 00, 00, 0e, 02, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, c3, 01, c7, 01, 00, 0d, 00, 15, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, b6, 01, 00, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, 00, b2, 01, b6, 01, 00, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, af, 01, 15, 00, b2, 01, b6, 01, 00, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, aa, 01, cb, 01, af, 01, 15, 00, b2, 01, b6, 01, 00, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, 19, 25, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 0e, 01, 0e, 00, 0f, 0b, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, ba, 01, 02, 0d, 00, 0e, bf, 01, 00, 12, 00, 17, ba, 01, 01, 10, 00, 15, 00, 00, 16, 01, 0e, b6, 01, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, b2, 01, 01, 12, 00, 13, af, 01, 01, 11, 00, 22, aa, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, a7, 01, 01, 05, 00, 06]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 51
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(2)
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Expression(0, Sub), rhs = Zero
 - expression 2 operands: lhs = Zero, rhs = Expression(3, Sub)
-- expression 3 operands: lhs = Expression(0, Sub), rhs = Counter(2)
+- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero
 - expression 4 operands: lhs = Expression(47, Add), rhs = Counter(6)
 - expression 5 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
-- expression 6 operands: lhs = Counter(1), rhs = Counter(3)
-- expression 7 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 6 operands: lhs = Zero, rhs = Counter(3)
+- expression 7 operands: lhs = Zero, rhs = Counter(5)
 - expression 8 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
-- expression 9 operands: lhs = Counter(1), rhs = Counter(3)
-- expression 10 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 9 operands: lhs = Zero, rhs = Counter(3)
+- expression 10 operands: lhs = Zero, rhs = Counter(5)
 - expression 11 operands: lhs = Expression(47, Add), rhs = Counter(6)
 - expression 12 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
-- expression 13 operands: lhs = Counter(1), rhs = Counter(3)
-- expression 14 operands: lhs = Counter(4), rhs = Counter(5)
-- expression 15 operands: lhs = Expression(46, Sub), rhs = Counter(4)
+- expression 13 operands: lhs = Zero, rhs = Counter(3)
+- expression 14 operands: lhs = Zero, rhs = Counter(5)
+- expression 15 operands: lhs = Expression(46, Sub), rhs = Zero
 - expression 16 operands: lhs = Expression(47, Add), rhs = Counter(6)
 - expression 17 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
-- expression 18 operands: lhs = Counter(1), rhs = Counter(3)
-- expression 19 operands: lhs = Counter(4), rhs = Counter(5)
-- expression 20 operands: lhs = Expression(45, Sub), rhs = Counter(7)
-- expression 21 operands: lhs = Expression(46, Sub), rhs = Counter(4)
+- expression 18 operands: lhs = Zero, rhs = Counter(3)
+- expression 19 operands: lhs = Zero, rhs = Counter(5)
+- expression 20 operands: lhs = Expression(45, Sub), rhs = Zero
+- expression 21 operands: lhs = Expression(46, Sub), rhs = Zero
 - expression 22 operands: lhs = Expression(47, Add), rhs = Counter(6)
 - expression 23 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
-- expression 24 operands: lhs = Counter(1), rhs = Counter(3)
-- expression 25 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 24 operands: lhs = Zero, rhs = Counter(3)
+- expression 25 operands: lhs = Zero, rhs = Counter(5)
 - expression 26 operands: lhs = Zero, rhs = Expression(44, Sub)
-- expression 27 operands: lhs = Expression(45, Sub), rhs = Counter(7)
-- expression 28 operands: lhs = Expression(46, Sub), rhs = Counter(4)
+- expression 27 operands: lhs = Expression(45, Sub), rhs = Zero
+- expression 28 operands: lhs = Expression(46, Sub), rhs = Zero
 - expression 29 operands: lhs = Expression(47, Add), rhs = Counter(6)
 - expression 30 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
-- expression 31 operands: lhs = Counter(1), rhs = Counter(3)
-- expression 32 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 31 operands: lhs = Zero, rhs = Counter(3)
+- expression 32 operands: lhs = Zero, rhs = Counter(5)
 - expression 33 operands: lhs = Expression(43, Add), rhs = Counter(5)
 - expression 34 operands: lhs = Zero, rhs = Expression(44, Sub)
-- expression 35 operands: lhs = Expression(45, Sub), rhs = Counter(7)
-- expression 36 operands: lhs = Expression(46, Sub), rhs = Counter(4)
+- expression 35 operands: lhs = Expression(45, Sub), rhs = Zero
+- expression 36 operands: lhs = Expression(46, Sub), rhs = Zero
 - expression 37 operands: lhs = Expression(47, Add), rhs = Counter(6)
 - expression 38 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
-- expression 39 operands: lhs = Counter(1), rhs = Counter(3)
-- expression 40 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 39 operands: lhs = Zero, rhs = Counter(3)
+- expression 40 operands: lhs = Zero, rhs = Counter(5)
 - expression 41 operands: lhs = Expression(42, Sub), rhs = Expression(50, Add)
 - expression 42 operands: lhs = Expression(43, Add), rhs = Counter(5)
 - expression 43 operands: lhs = Zero, rhs = Expression(44, Sub)
-- expression 44 operands: lhs = Expression(45, Sub), rhs = Counter(7)
-- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(4)
+- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero
+- expression 45 operands: lhs = Expression(46, Sub), rhs = Zero
 - expression 46 operands: lhs = Expression(47, Add), rhs = Counter(6)
 - expression 47 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
-- expression 48 operands: lhs = Counter(1), rhs = Counter(3)
-- expression 49 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 48 operands: lhs = Zero, rhs = Counter(3)
+- expression 49 operands: lhs = Zero, rhs = Counter(5)
 - expression 50 operands: lhs = Counter(6), rhs = Counter(9)
 Number of file 0 mappings: 20
 - Code(Counter(0)) at (prev + 34, 5) to (start + 1, 17)
 - Code(Zero) at (prev + 1, 18) to (start + 1, 10)
 - Code(Expression(0, Sub)) at (prev + 2, 16) to (start + 0, 21)
-    = (c0 - c1)
+    = (c0 - Zero)
 - Code(Zero) at (prev + 1, 23) to (start + 0, 27)
 - Code(Zero) at (prev + 0, 28) to (start + 0, 30)
 - Code(Expression(3, Sub)) at (prev + 1, 14) to (start + 0, 15)
-    = ((c0 - c1) - c2)
+    = ((c0 - Zero) - Zero)
 - Code(Expression(2, Add)) at (prev + 1, 13) to (start + 0, 30)
-    = (Zero + ((c0 - c1) - c2))
+    = (Zero + ((c0 - Zero) - Zero))
 - Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31)
 - Code(Expression(46, Sub)) at (prev + 2, 13) to (start + 0, 14)
-    = (((c1 + c3) + (c4 + c5)) - c6)
+    = (((Zero + c3) + (Zero + c5)) - c6)
 - Code(Expression(47, Add)) at (prev + 0, 18) to (start + 0, 23)
-    = ((c1 + c3) + (c4 + c5))
+    = ((Zero + c3) + (Zero + c5))
 - Code(Expression(46, Sub)) at (prev + 1, 16) to (start + 0, 21)
-    = (((c1 + c3) + (c4 + c5)) - c6)
+    = (((Zero + c3) + (Zero + c5)) - c6)
 - Code(Zero) at (prev + 0, 22) to (start + 1, 14)
 - Code(Expression(45, Sub)) at (prev + 2, 20) to (start + 0, 25)
-    = ((((c1 + c3) + (c4 + c5)) - c6) - c4)
+    = ((((Zero + c3) + (Zero + c5)) - c6) - Zero)
 - Code(Zero) at (prev + 1, 27) to (start + 0, 31)
 - Code(Zero) at (prev + 0, 32) to (start + 0, 34)
 - Code(Expression(44, Sub)) at (prev + 1, 18) to (start + 0, 19)
-    = (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)
+    = (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)
 - Code(Expression(43, Add)) at (prev + 1, 17) to (start + 0, 34)
-    = (Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7))
+    = (Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero))
 - Code(Expression(42, Sub)) at (prev + 0, 34) to (start + 0, 35)
-    = ((Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) - c5)
+    = ((Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)) - c5)
 - Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15)
 - Code(Expression(41, Add)) at (prev + 1, 5) to (start + 0, 6)
-    = (((Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) - c5) + (c6 + c9))
+    = (((Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)) - c5) + (c6 + c9))
 
 Function name: loops_branches::main
 Raw bytes (9): 0x[01, 01, 00, 01, 01, 37, 01, 05, 02]
diff --git a/tests/coverage-map/status-quo/sort_groups.cov-map b/tests/coverage-map/status-quo/sort_groups.cov-map
index 7156a66cf89..db027f3dc32 100644
--- a/tests/coverage-map/status-quo/sort_groups.cov-map
+++ b/tests/coverage-map/status-quo/sort_groups.cov-map
@@ -44,19 +44,19 @@ Number of file 0 mappings: 4
     = (c1 + (c0 - c1))
 
 Function name: sort_groups::main
-Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 04, 0d, 00, 04, 0e, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02]
+Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 06, 01, 04, 0d, 00, 04, 0e, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 2
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 6, 1) to (start + 4, 13)
 - Code(Zero) at (prev + 4, 14) to (start + 2, 6)
 - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
-    = (c0 - c1)
+    = (c0 - Zero)
 - Code(Expression(1, Add)) at (prev + 1, 5) to (start + 2, 2)
-    = (c1 + (c0 - c1))
+    = (Zero + (c0 - Zero))
 
 Function name: sort_groups::other_fn
 Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11]
diff --git a/tests/coverage-map/status-quo/tight_inf_loop.cov-map b/tests/coverage-map/status-quo/tight_inf_loop.cov-map
index 76884212c14..7fe3146b080 100644
--- a/tests/coverage-map/status-quo/tight_inf_loop.cov-map
+++ b/tests/coverage-map/status-quo/tight_inf_loop.cov-map
@@ -1,12 +1,12 @@
 Function name: tight_inf_loop::main
-Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 01, 01, 01, 0d, 00, 02, 09, 00, 10, 02, 01, 06, 01, 02]
+Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 01, 01, 01, 0d, 00, 02, 09, 00, 10, 02, 01, 06, 01, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 1
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 0 operands: lhs = Counter(0), rhs = Zero
 Number of file 0 mappings: 3
 - Code(Counter(0)) at (prev + 1, 1) to (start + 1, 13)
 - Code(Zero) at (prev + 2, 9) to (start + 0, 16)
 - Code(Expression(0, Sub)) at (prev + 1, 6) to (start + 1, 2)
-    = (c0 - c1)
+    = (c0 - Zero)
 
diff --git a/tests/coverage-map/status-quo/while.cov-map b/tests/coverage-map/status-quo/while.cov-map
index cfd2be96a0d..af250f3fb71 100644
--- a/tests/coverage-map/status-quo/while.cov-map
+++ b/tests/coverage-map/status-quo/while.cov-map
@@ -1,15 +1,15 @@
 Function name: while::main
-Raw bytes (28): 0x[01, 01, 02, 01, 05, 03, 05, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 01, 06, 06, 02, 01, 00, 02]
+Raw bytes (28): 0x[01, 01, 02, 01, 00, 03, 00, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 01, 06, 06, 02, 01, 00, 02]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 2
-- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
-- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(1)
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Expression(0, Add), rhs = Zero
 Number of file 0 mappings: 4
 - Code(Counter(0)) at (prev + 1, 1) to (start + 1, 16)
 - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 20)
-    = (c0 + c1)
+    = (c0 + Zero)
 - Code(Zero) at (prev + 0, 21) to (start + 1, 6)
 - Code(Expression(1, Sub)) at (prev + 2, 1) to (start + 0, 2)
-    = ((c0 + c1) - c1)
+    = ((c0 + Zero) - Zero)
 
diff --git a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
index 313e5dddbbb..f5d822520a7 100644
--- a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
+++ b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
@@ -4,12 +4,6 @@
   fn main() -> () {
       let mut _0: ();
       let _1: u8;
-      let mut _5: u8;
-      let mut _6: u8;
-      let mut _7: u8;
-      let mut _8: u8;
-      let mut _12: u32;
-      let mut _13: u32;
       scope 1 {
 -         debug x => _1;
 +         debug x => const 1_u8;
@@ -25,34 +19,34 @@
                   scope 4 {
 -                     debug sum => _4;
 +                     debug sum => const 6_u8;
-                      let _9: &str;
+                      let _5: &str;
                       scope 5 {
--                         debug s => _9;
+-                         debug s => _5;
 +                         debug s => const "hello, world!";
-                          let _14: bool;
-                          let _15: bool;
-                          let _16: u32;
+                          let _8: bool;
+                          let _9: bool;
+                          let _10: u32;
                           scope 6 {
--                             debug ((f: (bool, bool, u32)).0: bool) => _14;
--                             debug ((f: (bool, bool, u32)).1: bool) => _15;
--                             debug ((f: (bool, bool, u32)).2: u32) => _16;
+-                             debug ((f: (bool, bool, u32)).0: bool) => _8;
+-                             debug ((f: (bool, bool, u32)).1: bool) => _9;
+-                             debug ((f: (bool, bool, u32)).2: u32) => _10;
 +                             debug ((f: (bool, bool, u32)).0: bool) => const true;
 +                             debug ((f: (bool, bool, u32)).1: bool) => const false;
 +                             debug ((f: (bool, bool, u32)).2: u32) => const 123_u32;
-                              let _10: std::option::Option<u16>;
+                              let _6: std::option::Option<u16>;
                               scope 7 {
--                                 debug o => _10;
+-                                 debug o => _6;
 +                                 debug o => const Option::<u16>::Some(99_u16);
-                                  let _17: u32;
-                                  let _18: u32;
+                                  let _11: u32;
+                                  let _12: u32;
                                   scope 8 {
--                                     debug ((p: Point).0: u32) => _17;
--                                     debug ((p: Point).1: u32) => _18;
+-                                     debug ((p: Point).0: u32) => _11;
+-                                     debug ((p: Point).1: u32) => _12;
 +                                     debug ((p: Point).0: u32) => const 32_u32;
 +                                     debug ((p: Point).1: u32) => const 32_u32;
-                                      let _11: u32;
+                                      let _7: u32;
                                       scope 9 {
--                                         debug a => _11;
+-                                         debug a => _7;
 +                                         debug a => const 64_u32;
                                       }
                                   }
@@ -69,30 +63,27 @@
           _2 = const 2_u8;
           _3 = const 3_u8;
           StorageLive(_4);
-          StorageLive(_5);
-          _5 = const 3_u8;
           _4 = const 6_u8;
-          StorageDead(_5);
+          StorageLive(_5);
+          _5 = const "hello, world!";
+          StorageLive(_8);
           StorageLive(_9);
-          _9 = const "hello, world!";
-          StorageLive(_14);
-          StorageLive(_15);
-          StorageLive(_16);
-          _14 = const true;
-          _15 = const false;
-          _16 = const 123_u32;
           StorageLive(_10);
-          _10 = const Option::<u16>::Some(99_u16);
-          _17 = const 32_u32;
-          _18 = const 32_u32;
-          StorageLive(_11);
-          _11 = const 64_u32;
-          StorageDead(_11);
-          StorageDead(_10);
-          StorageDead(_14);
-          StorageDead(_15);
-          StorageDead(_16);
+          _8 = const true;
+          _9 = const false;
+          _10 = const 123_u32;
+          StorageLive(_6);
+          _6 = const Option::<u16>::Some(99_u16);
+          _11 = const 32_u32;
+          _12 = const 32_u32;
+          StorageLive(_7);
+          _7 = const 64_u32;
+          StorageDead(_7);
+          StorageDead(_6);
+          StorageDead(_8);
           StorageDead(_9);
+          StorageDead(_10);
+          StorageDead(_5);
           StorageDead(_4);
           return;
       }
diff --git a/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff
index 3f5173c189e..d524ad242fe 100644
--- a/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff
@@ -67,11 +67,11 @@
       bb0: {
           StorageLive(_2);
           StorageLive(_3);
--         StorageLive(_4);
--         _4 = _1;
+          StorageLive(_4);
+          _4 = _1;
 -         _3 = Add(move _4, const 0_u64);
--         StorageDead(_4);
 +         _3 = Add(_1, const 0_u64);
+          StorageDead(_4);
           _2 = opaque::<u64>(move _3) -> [return: bb1, unwind unreachable];
       }
   
@@ -80,11 +80,11 @@
           StorageDead(_2);
           StorageLive(_5);
           StorageLive(_6);
--         StorageLive(_7);
--         _7 = _1;
+          StorageLive(_7);
+          _7 = _1;
 -         _6 = Sub(move _7, const 0_u64);
--         StorageDead(_7);
 +         _6 = Sub(_1, const 0_u64);
+          StorageDead(_7);
           _5 = opaque::<u64>(move _6) -> [return: bb2, unwind unreachable];
       }
   
@@ -93,11 +93,11 @@
           StorageDead(_5);
           StorageLive(_8);
           StorageLive(_9);
--         StorageLive(_10);
--         _10 = _1;
+          StorageLive(_10);
+          _10 = _1;
 -         _9 = Mul(move _10, const 0_u64);
--         StorageDead(_10);
 +         _9 = Mul(_1, const 0_u64);
+          StorageDead(_10);
           _8 = opaque::<u64>(move _9) -> [return: bb3, unwind unreachable];
       }
   
@@ -106,11 +106,11 @@
           StorageDead(_8);
           StorageLive(_11);
           StorageLive(_12);
--         StorageLive(_13);
--         _13 = _1;
+          StorageLive(_13);
+          _13 = _1;
 -         _12 = Mul(move _13, const 1_u64);
--         StorageDead(_13);
 +         _12 = Mul(_1, const 1_u64);
+          StorageDead(_13);
           _11 = opaque::<u64>(move _12) -> [return: bb4, unwind unreachable];
       }
   
@@ -119,17 +119,18 @@
           StorageDead(_11);
           StorageLive(_14);
           StorageLive(_15);
--         StorageLive(_16);
--         _16 = _1;
-          _17 = Eq(const 0_u64, const 0_u64);
+          StorageLive(_16);
+          _16 = _1;
+-         _17 = Eq(const 0_u64, const 0_u64);
 -         assert(!move _17, "attempt to divide `{}` by zero", _16) -> [success: bb5, unwind unreachable];
-+         assert(!_17, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind unreachable];
++         _17 = const true;
++         assert(!const true, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind unreachable];
       }
   
       bb5: {
 -         _15 = Div(move _16, const 0_u64);
--         StorageDead(_16);
 +         _15 = Div(_1, const 0_u64);
+          StorageDead(_16);
           _14 = opaque::<u64>(move _15) -> [return: bb6, unwind unreachable];
       }
   
@@ -138,17 +139,18 @@
           StorageDead(_14);
           StorageLive(_18);
           StorageLive(_19);
--         StorageLive(_20);
--         _20 = _1;
-          _21 = Eq(const 1_u64, const 0_u64);
+          StorageLive(_20);
+          _20 = _1;
+-         _21 = Eq(const 1_u64, const 0_u64);
 -         assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb7, unwind unreachable];
-+         assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind unreachable];
++         _21 = const false;
++         assert(!const false, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind unreachable];
       }
   
       bb7: {
 -         _19 = Div(move _20, const 1_u64);
--         StorageDead(_20);
 +         _19 = Div(_1, const 1_u64);
+          StorageDead(_20);
           _18 = opaque::<u64>(move _19) -> [return: bb8, unwind unreachable];
       }
   
@@ -157,8 +159,8 @@
           StorageDead(_18);
           StorageLive(_22);
           StorageLive(_23);
--         StorageLive(_24);
--         _24 = _1;
+          StorageLive(_24);
+          _24 = _1;
 -         _25 = Eq(_24, const 0_u64);
 -         assert(!move _25, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb9, unwind unreachable];
 +         _25 = Eq(_1, const 0_u64);
@@ -167,8 +169,8 @@
   
       bb9: {
 -         _23 = Div(const 0_u64, move _24);
--         StorageDead(_24);
 +         _23 = Div(const 0_u64, _1);
+          StorageDead(_24);
           _22 = opaque::<u64>(move _23) -> [return: bb10, unwind unreachable];
       }
   
@@ -177,17 +179,18 @@
           StorageDead(_22);
           StorageLive(_26);
           StorageLive(_27);
--         StorageLive(_28);
--         _28 = _1;
+          StorageLive(_28);
+          _28 = _1;
 -         _29 = Eq(_28, const 0_u64);
 -         assert(!move _29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind unreachable];
++         _29 = _25;
 +         assert(!_25, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind unreachable];
       }
   
       bb11: {
 -         _27 = Div(const 1_u64, move _28);
--         StorageDead(_28);
 +         _27 = Div(const 1_u64, _1);
+          StorageDead(_28);
           _26 = opaque::<u64>(move _27) -> [return: bb12, unwind unreachable];
       }
   
@@ -196,17 +199,18 @@
           StorageDead(_26);
           StorageLive(_30);
           StorageLive(_31);
--         StorageLive(_32);
--         _32 = _1;
+          StorageLive(_32);
+          _32 = _1;
 -         _33 = Eq(const 0_u64, const 0_u64);
 -         assert(!move _33, "attempt to calculate the remainder of `{}` with a divisor of zero", _32) -> [success: bb13, unwind unreachable];
-+         assert(!_17, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind unreachable];
++         _33 = const true;
++         assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind unreachable];
       }
   
       bb13: {
 -         _31 = Rem(move _32, const 0_u64);
--         StorageDead(_32);
 +         _31 = Rem(_1, const 0_u64);
+          StorageDead(_32);
           _30 = opaque::<u64>(move _31) -> [return: bb14, unwind unreachable];
       }
   
@@ -215,17 +219,18 @@
           StorageDead(_30);
           StorageLive(_34);
           StorageLive(_35);
--         StorageLive(_36);
--         _36 = _1;
+          StorageLive(_36);
+          _36 = _1;
 -         _37 = Eq(const 1_u64, const 0_u64);
 -         assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb15, unwind unreachable];
-+         assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind unreachable];
++         _37 = const false;
++         assert(!const false, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind unreachable];
       }
   
       bb15: {
 -         _35 = Rem(move _36, const 1_u64);
--         StorageDead(_36);
 +         _35 = Rem(_1, const 1_u64);
+          StorageDead(_36);
           _34 = opaque::<u64>(move _35) -> [return: bb16, unwind unreachable];
       }
   
@@ -234,17 +239,18 @@
           StorageDead(_34);
           StorageLive(_38);
           StorageLive(_39);
--         StorageLive(_40);
--         _40 = _1;
+          StorageLive(_40);
+          _40 = _1;
 -         _41 = Eq(_40, const 0_u64);
 -         assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind unreachable];
++         _41 = _25;
 +         assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind unreachable];
       }
   
       bb17: {
 -         _39 = Rem(const 0_u64, move _40);
--         StorageDead(_40);
 +         _39 = Rem(const 0_u64, _1);
+          StorageDead(_40);
           _38 = opaque::<u64>(move _39) -> [return: bb18, unwind unreachable];
       }
   
@@ -253,17 +259,18 @@
           StorageDead(_38);
           StorageLive(_42);
           StorageLive(_43);
--         StorageLive(_44);
--         _44 = _1;
+          StorageLive(_44);
+          _44 = _1;
 -         _45 = Eq(_44, const 0_u64);
 -         assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind unreachable];
++         _45 = _25;
 +         assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind unreachable];
       }
   
       bb19: {
 -         _43 = Rem(const 1_u64, move _44);
--         StorageDead(_44);
 +         _43 = Rem(const 1_u64, _1);
+          StorageDead(_44);
           _42 = opaque::<u64>(move _43) -> [return: bb20, unwind unreachable];
       }
   
@@ -272,11 +279,11 @@
           StorageDead(_42);
           StorageLive(_46);
           StorageLive(_47);
--         StorageLive(_48);
--         _48 = _1;
+          StorageLive(_48);
+          _48 = _1;
 -         _47 = BitAnd(move _48, const 0_u64);
--         StorageDead(_48);
 +         _47 = BitAnd(_1, const 0_u64);
+          StorageDead(_48);
           _46 = opaque::<u64>(move _47) -> [return: bb21, unwind unreachable];
       }
   
@@ -285,11 +292,11 @@
           StorageDead(_46);
           StorageLive(_49);
           StorageLive(_50);
--         StorageLive(_51);
--         _51 = _1;
+          StorageLive(_51);
+          _51 = _1;
 -         _50 = BitOr(move _51, const 0_u64);
--         StorageDead(_51);
 +         _50 = BitOr(_1, const 0_u64);
+          StorageDead(_51);
           _49 = opaque::<u64>(move _50) -> [return: bb22, unwind unreachable];
       }
   
@@ -298,11 +305,11 @@
           StorageDead(_49);
           StorageLive(_52);
           StorageLive(_53);
--         StorageLive(_54);
--         _54 = _1;
+          StorageLive(_54);
+          _54 = _1;
 -         _53 = BitXor(move _54, const 0_u64);
--         StorageDead(_54);
 +         _53 = BitXor(_1, const 0_u64);
+          StorageDead(_54);
           _52 = opaque::<u64>(move _53) -> [return: bb23, unwind unreachable];
       }
   
@@ -311,11 +318,11 @@
           StorageDead(_52);
           StorageLive(_55);
           StorageLive(_56);
--         StorageLive(_57);
--         _57 = _1;
+          StorageLive(_57);
+          _57 = _1;
 -         _56 = Shr(move _57, const 0_i32);
--         StorageDead(_57);
 +         _56 = Shr(_1, const 0_i32);
+          StorageDead(_57);
           _55 = opaque::<u64>(move _56) -> [return: bb24, unwind unreachable];
       }
   
@@ -324,11 +331,11 @@
           StorageDead(_55);
           StorageLive(_58);
           StorageLive(_59);
--         StorageLive(_60);
--         _60 = _1;
+          StorageLive(_60);
+          _60 = _1;
 -         _59 = Shl(move _60, const 0_i32);
--         StorageDead(_60);
 +         _59 = Shl(_1, const 0_i32);
+          StorageDead(_60);
           _58 = opaque::<u64>(move _59) -> [return: bb25, unwind unreachable];
       }
   
diff --git a/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff
index 38da21d91d4..9d69353934c 100644
--- a/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff
@@ -67,11 +67,11 @@
       bb0: {
           StorageLive(_2);
           StorageLive(_3);
--         StorageLive(_4);
--         _4 = _1;
+          StorageLive(_4);
+          _4 = _1;
 -         _3 = Add(move _4, const 0_u64);
--         StorageDead(_4);
 +         _3 = Add(_1, const 0_u64);
+          StorageDead(_4);
           _2 = opaque::<u64>(move _3) -> [return: bb1, unwind continue];
       }
   
@@ -80,11 +80,11 @@
           StorageDead(_2);
           StorageLive(_5);
           StorageLive(_6);
--         StorageLive(_7);
--         _7 = _1;
+          StorageLive(_7);
+          _7 = _1;
 -         _6 = Sub(move _7, const 0_u64);
--         StorageDead(_7);
 +         _6 = Sub(_1, const 0_u64);
+          StorageDead(_7);
           _5 = opaque::<u64>(move _6) -> [return: bb2, unwind continue];
       }
   
@@ -93,11 +93,11 @@
           StorageDead(_5);
           StorageLive(_8);
           StorageLive(_9);
--         StorageLive(_10);
--         _10 = _1;
+          StorageLive(_10);
+          _10 = _1;
 -         _9 = Mul(move _10, const 0_u64);
--         StorageDead(_10);
 +         _9 = Mul(_1, const 0_u64);
+          StorageDead(_10);
           _8 = opaque::<u64>(move _9) -> [return: bb3, unwind continue];
       }
   
@@ -106,11 +106,11 @@
           StorageDead(_8);
           StorageLive(_11);
           StorageLive(_12);
--         StorageLive(_13);
--         _13 = _1;
+          StorageLive(_13);
+          _13 = _1;
 -         _12 = Mul(move _13, const 1_u64);
--         StorageDead(_13);
 +         _12 = Mul(_1, const 1_u64);
+          StorageDead(_13);
           _11 = opaque::<u64>(move _12) -> [return: bb4, unwind continue];
       }
   
@@ -119,17 +119,18 @@
           StorageDead(_11);
           StorageLive(_14);
           StorageLive(_15);
--         StorageLive(_16);
--         _16 = _1;
-          _17 = Eq(const 0_u64, const 0_u64);
+          StorageLive(_16);
+          _16 = _1;
+-         _17 = Eq(const 0_u64, const 0_u64);
 -         assert(!move _17, "attempt to divide `{}` by zero", _16) -> [success: bb5, unwind continue];
-+         assert(!_17, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind continue];
++         _17 = const true;
++         assert(!const true, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind continue];
       }
   
       bb5: {
 -         _15 = Div(move _16, const 0_u64);
--         StorageDead(_16);
 +         _15 = Div(_1, const 0_u64);
+          StorageDead(_16);
           _14 = opaque::<u64>(move _15) -> [return: bb6, unwind continue];
       }
   
@@ -138,17 +139,18 @@
           StorageDead(_14);
           StorageLive(_18);
           StorageLive(_19);
--         StorageLive(_20);
--         _20 = _1;
-          _21 = Eq(const 1_u64, const 0_u64);
+          StorageLive(_20);
+          _20 = _1;
+-         _21 = Eq(const 1_u64, const 0_u64);
 -         assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb7, unwind continue];
-+         assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind continue];
++         _21 = const false;
++         assert(!const false, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind continue];
       }
   
       bb7: {
 -         _19 = Div(move _20, const 1_u64);
--         StorageDead(_20);
 +         _19 = Div(_1, const 1_u64);
+          StorageDead(_20);
           _18 = opaque::<u64>(move _19) -> [return: bb8, unwind continue];
       }
   
@@ -157,8 +159,8 @@
           StorageDead(_18);
           StorageLive(_22);
           StorageLive(_23);
--         StorageLive(_24);
--         _24 = _1;
+          StorageLive(_24);
+          _24 = _1;
 -         _25 = Eq(_24, const 0_u64);
 -         assert(!move _25, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb9, unwind continue];
 +         _25 = Eq(_1, const 0_u64);
@@ -167,8 +169,8 @@
   
       bb9: {
 -         _23 = Div(const 0_u64, move _24);
--         StorageDead(_24);
 +         _23 = Div(const 0_u64, _1);
+          StorageDead(_24);
           _22 = opaque::<u64>(move _23) -> [return: bb10, unwind continue];
       }
   
@@ -177,17 +179,18 @@
           StorageDead(_22);
           StorageLive(_26);
           StorageLive(_27);
--         StorageLive(_28);
--         _28 = _1;
+          StorageLive(_28);
+          _28 = _1;
 -         _29 = Eq(_28, const 0_u64);
 -         assert(!move _29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind continue];
++         _29 = _25;
 +         assert(!_25, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind continue];
       }
   
       bb11: {
 -         _27 = Div(const 1_u64, move _28);
--         StorageDead(_28);
 +         _27 = Div(const 1_u64, _1);
+          StorageDead(_28);
           _26 = opaque::<u64>(move _27) -> [return: bb12, unwind continue];
       }
   
@@ -196,17 +199,18 @@
           StorageDead(_26);
           StorageLive(_30);
           StorageLive(_31);
--         StorageLive(_32);
--         _32 = _1;
+          StorageLive(_32);
+          _32 = _1;
 -         _33 = Eq(const 0_u64, const 0_u64);
 -         assert(!move _33, "attempt to calculate the remainder of `{}` with a divisor of zero", _32) -> [success: bb13, unwind continue];
-+         assert(!_17, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind continue];
++         _33 = const true;
++         assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind continue];
       }
   
       bb13: {
 -         _31 = Rem(move _32, const 0_u64);
--         StorageDead(_32);
 +         _31 = Rem(_1, const 0_u64);
+          StorageDead(_32);
           _30 = opaque::<u64>(move _31) -> [return: bb14, unwind continue];
       }
   
@@ -215,17 +219,18 @@
           StorageDead(_30);
           StorageLive(_34);
           StorageLive(_35);
--         StorageLive(_36);
--         _36 = _1;
+          StorageLive(_36);
+          _36 = _1;
 -         _37 = Eq(const 1_u64, const 0_u64);
 -         assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb15, unwind continue];
-+         assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind continue];
++         _37 = const false;
++         assert(!const false, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind continue];
       }
   
       bb15: {
 -         _35 = Rem(move _36, const 1_u64);
--         StorageDead(_36);
 +         _35 = Rem(_1, const 1_u64);
+          StorageDead(_36);
           _34 = opaque::<u64>(move _35) -> [return: bb16, unwind continue];
       }
   
@@ -234,17 +239,18 @@
           StorageDead(_34);
           StorageLive(_38);
           StorageLive(_39);
--         StorageLive(_40);
--         _40 = _1;
+          StorageLive(_40);
+          _40 = _1;
 -         _41 = Eq(_40, const 0_u64);
 -         assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind continue];
++         _41 = _25;
 +         assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind continue];
       }
   
       bb17: {
 -         _39 = Rem(const 0_u64, move _40);
--         StorageDead(_40);
 +         _39 = Rem(const 0_u64, _1);
+          StorageDead(_40);
           _38 = opaque::<u64>(move _39) -> [return: bb18, unwind continue];
       }
   
@@ -253,17 +259,18 @@
           StorageDead(_38);
           StorageLive(_42);
           StorageLive(_43);
--         StorageLive(_44);
--         _44 = _1;
+          StorageLive(_44);
+          _44 = _1;
 -         _45 = Eq(_44, const 0_u64);
 -         assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind continue];
++         _45 = _25;
 +         assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind continue];
       }
   
       bb19: {
 -         _43 = Rem(const 1_u64, move _44);
--         StorageDead(_44);
 +         _43 = Rem(const 1_u64, _1);
+          StorageDead(_44);
           _42 = opaque::<u64>(move _43) -> [return: bb20, unwind continue];
       }
   
@@ -272,11 +279,11 @@
           StorageDead(_42);
           StorageLive(_46);
           StorageLive(_47);
--         StorageLive(_48);
--         _48 = _1;
+          StorageLive(_48);
+          _48 = _1;
 -         _47 = BitAnd(move _48, const 0_u64);
--         StorageDead(_48);
 +         _47 = BitAnd(_1, const 0_u64);
+          StorageDead(_48);
           _46 = opaque::<u64>(move _47) -> [return: bb21, unwind continue];
       }
   
@@ -285,11 +292,11 @@
           StorageDead(_46);
           StorageLive(_49);
           StorageLive(_50);
--         StorageLive(_51);
--         _51 = _1;
+          StorageLive(_51);
+          _51 = _1;
 -         _50 = BitOr(move _51, const 0_u64);
--         StorageDead(_51);
 +         _50 = BitOr(_1, const 0_u64);
+          StorageDead(_51);
           _49 = opaque::<u64>(move _50) -> [return: bb22, unwind continue];
       }
   
@@ -298,11 +305,11 @@
           StorageDead(_49);
           StorageLive(_52);
           StorageLive(_53);
--         StorageLive(_54);
--         _54 = _1;
+          StorageLive(_54);
+          _54 = _1;
 -         _53 = BitXor(move _54, const 0_u64);
--         StorageDead(_54);
 +         _53 = BitXor(_1, const 0_u64);
+          StorageDead(_54);
           _52 = opaque::<u64>(move _53) -> [return: bb23, unwind continue];
       }
   
@@ -311,11 +318,11 @@
           StorageDead(_52);
           StorageLive(_55);
           StorageLive(_56);
--         StorageLive(_57);
--         _57 = _1;
+          StorageLive(_57);
+          _57 = _1;
 -         _56 = Shr(move _57, const 0_i32);
--         StorageDead(_57);
 +         _56 = Shr(_1, const 0_i32);
+          StorageDead(_57);
           _55 = opaque::<u64>(move _56) -> [return: bb24, unwind continue];
       }
   
@@ -324,11 +331,11 @@
           StorageDead(_55);
           StorageLive(_58);
           StorageLive(_59);
--         StorageLive(_60);
--         _60 = _1;
+          StorageLive(_60);
+          _60 = _1;
 -         _59 = Shl(move _60, const 0_i32);
--         StorageDead(_60);
 +         _59 = Shl(_1, const 0_i32);
+          StorageDead(_60);
           _58 = opaque::<u64>(move _59) -> [return: bb25, unwind continue];
       }
   
diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff
index 0c342799e07..6633df3ae70 100644
--- a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff
@@ -20,63 +20,12 @@
       let mut _15: u64;
       let mut _16: u64;
       let mut _17: (u64, bool);
-      let _18: ();
-      let mut _19: u64;
-      let mut _20: u64;
-      let mut _21: bool;
-      let _22: ();
-      let mut _23: u64;
-      let mut _24: u64;
-      let mut _25: bool;
-      let _26: ();
-      let mut _27: u64;
-      let mut _28: u64;
-      let mut _29: bool;
-      let _30: ();
-      let mut _31: u64;
-      let mut _32: u64;
-      let mut _33: bool;
-      let _34: ();
-      let mut _35: u64;
-      let mut _36: u64;
-      let mut _37: bool;
-      let _38: ();
-      let mut _39: u64;
-      let mut _40: u64;
-      let mut _41: bool;
-      let _42: ();
-      let mut _43: u64;
-      let mut _44: u64;
-      let mut _45: bool;
-      let _46: ();
-      let mut _47: u64;
-      let mut _48: u64;
-      let mut _49: bool;
-      let _50: ();
-      let mut _51: u64;
-      let mut _52: u64;
-      let _53: ();
-      let mut _54: u64;
-      let mut _55: u64;
-      let _56: ();
-      let mut _57: u64;
-      let mut _58: u64;
-      let _59: ();
-      let mut _60: u64;
-      let mut _61: u64;
-      let mut _62: u32;
-      let mut _63: bool;
-      let _64: ();
-      let mut _65: u64;
-      let mut _66: u64;
-      let mut _67: u32;
-      let mut _68: bool;
   
       bb0: {
           StorageLive(_2);
           StorageLive(_3);
--         StorageLive(_4);
--         _4 = _1;
+          StorageLive(_4);
+          _4 = _1;
 -         _5 = CheckedAdd(_4, const 0_u64);
 -         assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, const 0_u64) -> [success: bb1, unwind unreachable];
 +         _5 = CheckedAdd(_1, const 0_u64);
@@ -85,7 +34,7 @@
   
       bb1: {
           _3 = move (_5.0: u64);
--         StorageDead(_4);
+          StorageDead(_4);
           _2 = opaque::<u64>(move _3) -> [return: bb2, unwind unreachable];
       }
   
@@ -94,8 +43,8 @@
           StorageDead(_2);
           StorageLive(_6);
           StorageLive(_7);
--         StorageLive(_8);
--         _8 = _1;
+          StorageLive(_8);
+          _8 = _1;
 -         _9 = CheckedSub(_8, const 0_u64);
 -         assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", move _8, const 0_u64) -> [success: bb3, unwind unreachable];
 +         _9 = CheckedSub(_1, const 0_u64);
@@ -104,7 +53,7 @@
   
       bb3: {
           _7 = move (_9.0: u64);
--         StorageDead(_8);
+          StorageDead(_8);
           _6 = opaque::<u64>(move _7) -> [return: bb4, unwind unreachable];
       }
   
@@ -113,8 +62,8 @@
           StorageDead(_6);
           StorageLive(_10);
           StorageLive(_11);
--         StorageLive(_12);
--         _12 = _1;
+          StorageLive(_12);
+          _12 = _1;
 -         _13 = CheckedMul(_12, const 0_u64);
 -         assert(!move (_13.1: bool), "attempt to compute `{} * {}`, which would overflow", move _12, const 0_u64) -> [success: bb5, unwind unreachable];
 +         _13 = CheckedMul(_1, const 0_u64);
@@ -123,7 +72,7 @@
   
       bb5: {
           _11 = move (_13.0: u64);
--         StorageDead(_12);
+          StorageDead(_12);
           _10 = opaque::<u64>(move _11) -> [return: bb6, unwind unreachable];
       }
   
@@ -132,8 +81,8 @@
           StorageDead(_10);
           StorageLive(_14);
           StorageLive(_15);
--         StorageLive(_16);
--         _16 = _1;
+          StorageLive(_16);
+          _16 = _1;
 -         _17 = CheckedMul(_16, const 1_u64);
 -         assert(!move (_17.1: bool), "attempt to compute `{} * {}`, which would overflow", move _16, const 1_u64) -> [success: bb7, unwind unreachable];
 +         _17 = CheckedMul(_1, const 1_u64);
@@ -142,246 +91,13 @@
   
       bb7: {
           _15 = move (_17.0: u64);
--         StorageDead(_16);
+          StorageDead(_16);
           _14 = opaque::<u64>(move _15) -> [return: bb8, unwind unreachable];
       }
   
       bb8: {
           StorageDead(_15);
           StorageDead(_14);
-          StorageLive(_18);
-          StorageLive(_19);
--         StorageLive(_20);
--         _20 = _1;
-          _21 = Eq(const 0_u64, const 0_u64);
--         assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb9, unwind unreachable];
-+         assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind unreachable];
-      }
-  
-      bb9: {
--         _19 = Div(move _20, const 0_u64);
--         StorageDead(_20);
-+         _19 = Div(_1, const 0_u64);
-          _18 = opaque::<u64>(move _19) -> [return: bb10, unwind unreachable];
-      }
-  
-      bb10: {
-          StorageDead(_19);
-          StorageDead(_18);
-          StorageLive(_22);
-          StorageLive(_23);
--         StorageLive(_24);
--         _24 = _1;
-          _25 = Eq(const 1_u64, const 0_u64);
--         assert(!move _25, "attempt to divide `{}` by zero", _24) -> [success: bb11, unwind unreachable];
-+         assert(!_25, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind unreachable];
-      }
-  
-      bb11: {
--         _23 = Div(move _24, const 1_u64);
--         StorageDead(_24);
-+         _23 = Div(_1, const 1_u64);
-          _22 = opaque::<u64>(move _23) -> [return: bb12, unwind unreachable];
-      }
-  
-      bb12: {
-          StorageDead(_23);
-          StorageDead(_22);
-          StorageLive(_26);
-          StorageLive(_27);
--         StorageLive(_28);
--         _28 = _1;
--         _29 = Eq(_28, const 0_u64);
--         assert(!move _29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind unreachable];
-+         _29 = Eq(_1, const 0_u64);
-+         assert(!_29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind unreachable];
-      }
-  
-      bb13: {
--         _27 = Div(const 0_u64, move _28);
--         StorageDead(_28);
-+         _27 = Div(const 0_u64, _1);
-          _26 = opaque::<u64>(move _27) -> [return: bb14, unwind unreachable];
-      }
-  
-      bb14: {
-          StorageDead(_27);
-          StorageDead(_26);
-          StorageLive(_30);
-          StorageLive(_31);
--         StorageLive(_32);
--         _32 = _1;
--         _33 = Eq(_32, const 0_u64);
--         assert(!move _33, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind unreachable];
-+         assert(!_29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind unreachable];
-      }
-  
-      bb15: {
--         _31 = Div(const 1_u64, move _32);
--         StorageDead(_32);
-+         _31 = Div(const 1_u64, _1);
-          _30 = opaque::<u64>(move _31) -> [return: bb16, unwind unreachable];
-      }
-  
-      bb16: {
-          StorageDead(_31);
-          StorageDead(_30);
-          StorageLive(_34);
-          StorageLive(_35);
--         StorageLive(_36);
--         _36 = _1;
--         _37 = Eq(const 0_u64, const 0_u64);
--         assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb17, unwind unreachable];
-+         assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind unreachable];
-      }
-  
-      bb17: {
--         _35 = Rem(move _36, const 0_u64);
--         StorageDead(_36);
-+         _35 = Rem(_1, const 0_u64);
-          _34 = opaque::<u64>(move _35) -> [return: bb18, unwind unreachable];
-      }
-  
-      bb18: {
-          StorageDead(_35);
-          StorageDead(_34);
-          StorageLive(_38);
-          StorageLive(_39);
--         StorageLive(_40);
--         _40 = _1;
--         _41 = Eq(const 1_u64, const 0_u64);
--         assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", _40) -> [success: bb19, unwind unreachable];
-+         assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind unreachable];
-      }
-  
-      bb19: {
--         _39 = Rem(move _40, const 1_u64);
--         StorageDead(_40);
-+         _39 = Rem(_1, const 1_u64);
-          _38 = opaque::<u64>(move _39) -> [return: bb20, unwind unreachable];
-      }
-  
-      bb20: {
-          StorageDead(_39);
-          StorageDead(_38);
-          StorageLive(_42);
-          StorageLive(_43);
--         StorageLive(_44);
--         _44 = _1;
--         _45 = Eq(_44, const 0_u64);
--         assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind unreachable];
-+         assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind unreachable];
-      }
-  
-      bb21: {
--         _43 = Rem(const 0_u64, move _44);
--         StorageDead(_44);
-+         _43 = Rem(const 0_u64, _1);
-          _42 = opaque::<u64>(move _43) -> [return: bb22, unwind unreachable];
-      }
-  
-      bb22: {
-          StorageDead(_43);
-          StorageDead(_42);
-          StorageLive(_46);
-          StorageLive(_47);
--         StorageLive(_48);
--         _48 = _1;
--         _49 = Eq(_48, const 0_u64);
--         assert(!move _49, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind unreachable];
-+         assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind unreachable];
-      }
-  
-      bb23: {
--         _47 = Rem(const 1_u64, move _48);
--         StorageDead(_48);
-+         _47 = Rem(const 1_u64, _1);
-          _46 = opaque::<u64>(move _47) -> [return: bb24, unwind unreachable];
-      }
-  
-      bb24: {
-          StorageDead(_47);
-          StorageDead(_46);
-          StorageLive(_50);
-          StorageLive(_51);
--         StorageLive(_52);
--         _52 = _1;
--         _51 = BitAnd(move _52, const 0_u64);
--         StorageDead(_52);
-+         _51 = BitAnd(_1, const 0_u64);
-          _50 = opaque::<u64>(move _51) -> [return: bb25, unwind unreachable];
-      }
-  
-      bb25: {
-          StorageDead(_51);
-          StorageDead(_50);
-          StorageLive(_53);
-          StorageLive(_54);
--         StorageLive(_55);
--         _55 = _1;
--         _54 = BitOr(move _55, const 0_u64);
--         StorageDead(_55);
-+         _54 = BitOr(_1, const 0_u64);
-          _53 = opaque::<u64>(move _54) -> [return: bb26, unwind unreachable];
-      }
-  
-      bb26: {
-          StorageDead(_54);
-          StorageDead(_53);
-          StorageLive(_56);
-          StorageLive(_57);
--         StorageLive(_58);
--         _58 = _1;
--         _57 = BitXor(move _58, const 0_u64);
--         StorageDead(_58);
-+         _57 = BitXor(_1, const 0_u64);
-          _56 = opaque::<u64>(move _57) -> [return: bb27, unwind unreachable];
-      }
-  
-      bb27: {
-          StorageDead(_57);
-          StorageDead(_56);
-          StorageLive(_59);
-          StorageLive(_60);
--         StorageLive(_61);
--         _61 = _1;
-          _62 = const 0_i32 as u32 (IntToInt);
--         _63 = Lt(move _62, const 64_u32);
--         assert(move _63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable];
-+         _63 = Lt(_62, const 64_u32);
-+         assert(_63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable];
-      }
-  
-      bb28: {
--         _60 = Shr(move _61, const 0_i32);
--         StorageDead(_61);
-+         _60 = Shr(_1, const 0_i32);
-          _59 = opaque::<u64>(move _60) -> [return: bb29, unwind unreachable];
-      }
-  
-      bb29: {
-          StorageDead(_60);
-          StorageDead(_59);
-          StorageLive(_64);
-          StorageLive(_65);
--         StorageLive(_66);
--         _66 = _1;
--         _67 = const 0_i32 as u32 (IntToInt);
--         _68 = Lt(move _67, const 64_u32);
--         assert(move _68, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable];
-+         assert(_63, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable];
-      }
-  
-      bb30: {
--         _65 = Shl(move _66, const 0_i32);
--         StorageDead(_66);
-+         _65 = Shl(_1, const 0_i32);
-          _64 = opaque::<u64>(move _65) -> [return: bb31, unwind unreachable];
-      }
-  
-      bb31: {
-          StorageDead(_65);
-          StorageDead(_64);
           _0 = const ();
           return;
       }
diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff
index 7813c29b962..d100a77fee5 100644
--- a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff
@@ -20,63 +20,12 @@
       let mut _15: u64;
       let mut _16: u64;
       let mut _17: (u64, bool);
-      let _18: ();
-      let mut _19: u64;
-      let mut _20: u64;
-      let mut _21: bool;
-      let _22: ();
-      let mut _23: u64;
-      let mut _24: u64;
-      let mut _25: bool;
-      let _26: ();
-      let mut _27: u64;
-      let mut _28: u64;
-      let mut _29: bool;
-      let _30: ();
-      let mut _31: u64;
-      let mut _32: u64;
-      let mut _33: bool;
-      let _34: ();
-      let mut _35: u64;
-      let mut _36: u64;
-      let mut _37: bool;
-      let _38: ();
-      let mut _39: u64;
-      let mut _40: u64;
-      let mut _41: bool;
-      let _42: ();
-      let mut _43: u64;
-      let mut _44: u64;
-      let mut _45: bool;
-      let _46: ();
-      let mut _47: u64;
-      let mut _48: u64;
-      let mut _49: bool;
-      let _50: ();
-      let mut _51: u64;
-      let mut _52: u64;
-      let _53: ();
-      let mut _54: u64;
-      let mut _55: u64;
-      let _56: ();
-      let mut _57: u64;
-      let mut _58: u64;
-      let _59: ();
-      let mut _60: u64;
-      let mut _61: u64;
-      let mut _62: u32;
-      let mut _63: bool;
-      let _64: ();
-      let mut _65: u64;
-      let mut _66: u64;
-      let mut _67: u32;
-      let mut _68: bool;
   
       bb0: {
           StorageLive(_2);
           StorageLive(_3);
--         StorageLive(_4);
--         _4 = _1;
+          StorageLive(_4);
+          _4 = _1;
 -         _5 = CheckedAdd(_4, const 0_u64);
 -         assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, const 0_u64) -> [success: bb1, unwind continue];
 +         _5 = CheckedAdd(_1, const 0_u64);
@@ -85,7 +34,7 @@
   
       bb1: {
           _3 = move (_5.0: u64);
--         StorageDead(_4);
+          StorageDead(_4);
           _2 = opaque::<u64>(move _3) -> [return: bb2, unwind continue];
       }
   
@@ -94,8 +43,8 @@
           StorageDead(_2);
           StorageLive(_6);
           StorageLive(_7);
--         StorageLive(_8);
--         _8 = _1;
+          StorageLive(_8);
+          _8 = _1;
 -         _9 = CheckedSub(_8, const 0_u64);
 -         assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", move _8, const 0_u64) -> [success: bb3, unwind continue];
 +         _9 = CheckedSub(_1, const 0_u64);
@@ -104,7 +53,7 @@
   
       bb3: {
           _7 = move (_9.0: u64);
--         StorageDead(_8);
+          StorageDead(_8);
           _6 = opaque::<u64>(move _7) -> [return: bb4, unwind continue];
       }
   
@@ -113,8 +62,8 @@
           StorageDead(_6);
           StorageLive(_10);
           StorageLive(_11);
--         StorageLive(_12);
--         _12 = _1;
+          StorageLive(_12);
+          _12 = _1;
 -         _13 = CheckedMul(_12, const 0_u64);
 -         assert(!move (_13.1: bool), "attempt to compute `{} * {}`, which would overflow", move _12, const 0_u64) -> [success: bb5, unwind continue];
 +         _13 = CheckedMul(_1, const 0_u64);
@@ -123,7 +72,7 @@
   
       bb5: {
           _11 = move (_13.0: u64);
--         StorageDead(_12);
+          StorageDead(_12);
           _10 = opaque::<u64>(move _11) -> [return: bb6, unwind continue];
       }
   
@@ -132,8 +81,8 @@
           StorageDead(_10);
           StorageLive(_14);
           StorageLive(_15);
--         StorageLive(_16);
--         _16 = _1;
+          StorageLive(_16);
+          _16 = _1;
 -         _17 = CheckedMul(_16, const 1_u64);
 -         assert(!move (_17.1: bool), "attempt to compute `{} * {}`, which would overflow", move _16, const 1_u64) -> [success: bb7, unwind continue];
 +         _17 = CheckedMul(_1, const 1_u64);
@@ -142,246 +91,13 @@
   
       bb7: {
           _15 = move (_17.0: u64);
--         StorageDead(_16);
+          StorageDead(_16);
           _14 = opaque::<u64>(move _15) -> [return: bb8, unwind continue];
       }
   
       bb8: {
           StorageDead(_15);
           StorageDead(_14);
-          StorageLive(_18);
-          StorageLive(_19);
--         StorageLive(_20);
--         _20 = _1;
-          _21 = Eq(const 0_u64, const 0_u64);
--         assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb9, unwind continue];
-+         assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind continue];
-      }
-  
-      bb9: {
--         _19 = Div(move _20, const 0_u64);
--         StorageDead(_20);
-+         _19 = Div(_1, const 0_u64);
-          _18 = opaque::<u64>(move _19) -> [return: bb10, unwind continue];
-      }
-  
-      bb10: {
-          StorageDead(_19);
-          StorageDead(_18);
-          StorageLive(_22);
-          StorageLive(_23);
--         StorageLive(_24);
--         _24 = _1;
-          _25 = Eq(const 1_u64, const 0_u64);
--         assert(!move _25, "attempt to divide `{}` by zero", _24) -> [success: bb11, unwind continue];
-+         assert(!_25, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind continue];
-      }
-  
-      bb11: {
--         _23 = Div(move _24, const 1_u64);
--         StorageDead(_24);
-+         _23 = Div(_1, const 1_u64);
-          _22 = opaque::<u64>(move _23) -> [return: bb12, unwind continue];
-      }
-  
-      bb12: {
-          StorageDead(_23);
-          StorageDead(_22);
-          StorageLive(_26);
-          StorageLive(_27);
--         StorageLive(_28);
--         _28 = _1;
--         _29 = Eq(_28, const 0_u64);
--         assert(!move _29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind continue];
-+         _29 = Eq(_1, const 0_u64);
-+         assert(!_29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind continue];
-      }
-  
-      bb13: {
--         _27 = Div(const 0_u64, move _28);
--         StorageDead(_28);
-+         _27 = Div(const 0_u64, _1);
-          _26 = opaque::<u64>(move _27) -> [return: bb14, unwind continue];
-      }
-  
-      bb14: {
-          StorageDead(_27);
-          StorageDead(_26);
-          StorageLive(_30);
-          StorageLive(_31);
--         StorageLive(_32);
--         _32 = _1;
--         _33 = Eq(_32, const 0_u64);
--         assert(!move _33, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind continue];
-+         assert(!_29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind continue];
-      }
-  
-      bb15: {
--         _31 = Div(const 1_u64, move _32);
--         StorageDead(_32);
-+         _31 = Div(const 1_u64, _1);
-          _30 = opaque::<u64>(move _31) -> [return: bb16, unwind continue];
-      }
-  
-      bb16: {
-          StorageDead(_31);
-          StorageDead(_30);
-          StorageLive(_34);
-          StorageLive(_35);
--         StorageLive(_36);
--         _36 = _1;
--         _37 = Eq(const 0_u64, const 0_u64);
--         assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb17, unwind continue];
-+         assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind continue];
-      }
-  
-      bb17: {
--         _35 = Rem(move _36, const 0_u64);
--         StorageDead(_36);
-+         _35 = Rem(_1, const 0_u64);
-          _34 = opaque::<u64>(move _35) -> [return: bb18, unwind continue];
-      }
-  
-      bb18: {
-          StorageDead(_35);
-          StorageDead(_34);
-          StorageLive(_38);
-          StorageLive(_39);
--         StorageLive(_40);
--         _40 = _1;
--         _41 = Eq(const 1_u64, const 0_u64);
--         assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", _40) -> [success: bb19, unwind continue];
-+         assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind continue];
-      }
-  
-      bb19: {
--         _39 = Rem(move _40, const 1_u64);
--         StorageDead(_40);
-+         _39 = Rem(_1, const 1_u64);
-          _38 = opaque::<u64>(move _39) -> [return: bb20, unwind continue];
-      }
-  
-      bb20: {
-          StorageDead(_39);
-          StorageDead(_38);
-          StorageLive(_42);
-          StorageLive(_43);
--         StorageLive(_44);
--         _44 = _1;
--         _45 = Eq(_44, const 0_u64);
--         assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind continue];
-+         assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind continue];
-      }
-  
-      bb21: {
--         _43 = Rem(const 0_u64, move _44);
--         StorageDead(_44);
-+         _43 = Rem(const 0_u64, _1);
-          _42 = opaque::<u64>(move _43) -> [return: bb22, unwind continue];
-      }
-  
-      bb22: {
-          StorageDead(_43);
-          StorageDead(_42);
-          StorageLive(_46);
-          StorageLive(_47);
--         StorageLive(_48);
--         _48 = _1;
--         _49 = Eq(_48, const 0_u64);
--         assert(!move _49, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind continue];
-+         assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind continue];
-      }
-  
-      bb23: {
--         _47 = Rem(const 1_u64, move _48);
--         StorageDead(_48);
-+         _47 = Rem(const 1_u64, _1);
-          _46 = opaque::<u64>(move _47) -> [return: bb24, unwind continue];
-      }
-  
-      bb24: {
-          StorageDead(_47);
-          StorageDead(_46);
-          StorageLive(_50);
-          StorageLive(_51);
--         StorageLive(_52);
--         _52 = _1;
--         _51 = BitAnd(move _52, const 0_u64);
--         StorageDead(_52);
-+         _51 = BitAnd(_1, const 0_u64);
-          _50 = opaque::<u64>(move _51) -> [return: bb25, unwind continue];
-      }
-  
-      bb25: {
-          StorageDead(_51);
-          StorageDead(_50);
-          StorageLive(_53);
-          StorageLive(_54);
--         StorageLive(_55);
--         _55 = _1;
--         _54 = BitOr(move _55, const 0_u64);
--         StorageDead(_55);
-+         _54 = BitOr(_1, const 0_u64);
-          _53 = opaque::<u64>(move _54) -> [return: bb26, unwind continue];
-      }
-  
-      bb26: {
-          StorageDead(_54);
-          StorageDead(_53);
-          StorageLive(_56);
-          StorageLive(_57);
--         StorageLive(_58);
--         _58 = _1;
--         _57 = BitXor(move _58, const 0_u64);
--         StorageDead(_58);
-+         _57 = BitXor(_1, const 0_u64);
-          _56 = opaque::<u64>(move _57) -> [return: bb27, unwind continue];
-      }
-  
-      bb27: {
-          StorageDead(_57);
-          StorageDead(_56);
-          StorageLive(_59);
-          StorageLive(_60);
--         StorageLive(_61);
--         _61 = _1;
-          _62 = const 0_i32 as u32 (IntToInt);
--         _63 = Lt(move _62, const 64_u32);
--         assert(move _63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue];
-+         _63 = Lt(_62, const 64_u32);
-+         assert(_63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue];
-      }
-  
-      bb28: {
--         _60 = Shr(move _61, const 0_i32);
--         StorageDead(_61);
-+         _60 = Shr(_1, const 0_i32);
-          _59 = opaque::<u64>(move _60) -> [return: bb29, unwind continue];
-      }
-  
-      bb29: {
-          StorageDead(_60);
-          StorageDead(_59);
-          StorageLive(_64);
-          StorageLive(_65);
--         StorageLive(_66);
--         _66 = _1;
--         _67 = const 0_i32 as u32 (IntToInt);
--         _68 = Lt(move _67, const 64_u32);
--         assert(move _68, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue];
-+         assert(_63, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue];
-      }
-  
-      bb30: {
--         _65 = Shl(move _66, const 0_i32);
--         StorageDead(_66);
-+         _65 = Shl(_1, const 0_i32);
-          _64 = opaque::<u64>(move _65) -> [return: bb31, unwind continue];
-      }
-  
-      bb31: {
-          StorageDead(_65);
-          StorageDead(_64);
           _0 = const ();
           return;
       }
diff --git a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff
index 7d5ac8353fe..b332100eaf0 100644
--- a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff
@@ -37,11 +37,11 @@
       bb0: {
           StorageLive(_2);
           StorageLive(_3);
--         StorageLive(_4);
--         _4 = _1;
+          StorageLive(_4);
+          _4 = _1;
 -         _3 = Add(move _4, const 0f64);
--         StorageDead(_4);
 +         _3 = Add(_1, const 0f64);
+          StorageDead(_4);
           _2 = opaque::<f64>(move _3) -> [return: bb1, unwind unreachable];
       }
   
@@ -50,11 +50,11 @@
           StorageDead(_2);
           StorageLive(_5);
           StorageLive(_6);
--         StorageLive(_7);
--         _7 = _1;
+          StorageLive(_7);
+          _7 = _1;
 -         _6 = Sub(move _7, const 0f64);
--         StorageDead(_7);
 +         _6 = Sub(_1, const 0f64);
+          StorageDead(_7);
           _5 = opaque::<f64>(move _6) -> [return: bb2, unwind unreachable];
       }
   
@@ -63,11 +63,11 @@
           StorageDead(_5);
           StorageLive(_8);
           StorageLive(_9);
--         StorageLive(_10);
--         _10 = _1;
+          StorageLive(_10);
+          _10 = _1;
 -         _9 = Mul(move _10, const 0f64);
--         StorageDead(_10);
 +         _9 = Mul(_1, const 0f64);
+          StorageDead(_10);
           _8 = opaque::<f64>(move _9) -> [return: bb3, unwind unreachable];
       }
   
@@ -76,11 +76,11 @@
           StorageDead(_8);
           StorageLive(_11);
           StorageLive(_12);
--         StorageLive(_13);
--         _13 = _1;
+          StorageLive(_13);
+          _13 = _1;
 -         _12 = Div(move _13, const 0f64);
--         StorageDead(_13);
 +         _12 = Div(_1, const 0f64);
+          StorageDead(_13);
           _11 = opaque::<f64>(move _12) -> [return: bb4, unwind unreachable];
       }
   
@@ -89,11 +89,11 @@
           StorageDead(_11);
           StorageLive(_14);
           StorageLive(_15);
--         StorageLive(_16);
--         _16 = _1;
+          StorageLive(_16);
+          _16 = _1;
 -         _15 = Div(const 0f64, move _16);
--         StorageDead(_16);
 +         _15 = Div(const 0f64, _1);
+          StorageDead(_16);
           _14 = opaque::<f64>(move _15) -> [return: bb5, unwind unreachable];
       }
   
@@ -102,11 +102,11 @@
           StorageDead(_14);
           StorageLive(_17);
           StorageLive(_18);
--         StorageLive(_19);
--         _19 = _1;
+          StorageLive(_19);
+          _19 = _1;
 -         _18 = Rem(move _19, const 0f64);
--         StorageDead(_19);
 +         _18 = Rem(_1, const 0f64);
+          StorageDead(_19);
           _17 = opaque::<f64>(move _18) -> [return: bb6, unwind unreachable];
       }
   
@@ -115,11 +115,11 @@
           StorageDead(_17);
           StorageLive(_20);
           StorageLive(_21);
--         StorageLive(_22);
--         _22 = _1;
+          StorageLive(_22);
+          _22 = _1;
 -         _21 = Rem(const 0f64, move _22);
--         StorageDead(_22);
 +         _21 = Rem(const 0f64, _1);
+          StorageDead(_22);
           _20 = opaque::<f64>(move _21) -> [return: bb7, unwind unreachable];
       }
   
@@ -128,14 +128,14 @@
           StorageDead(_20);
           StorageLive(_23);
           StorageLive(_24);
--         StorageLive(_25);
--         _25 = _1;
--         StorageLive(_26);
--         _26 = _1;
+          StorageLive(_25);
+          _25 = _1;
+          StorageLive(_26);
+          _26 = _1;
 -         _24 = Eq(move _25, move _26);
--         StorageDead(_26);
--         StorageDead(_25);
 +         _24 = Eq(_1, _1);
+          StorageDead(_26);
+          StorageDead(_25);
           _23 = opaque::<bool>(move _24) -> [return: bb8, unwind unreachable];
       }
   
@@ -144,14 +144,14 @@
           StorageDead(_23);
           StorageLive(_27);
           StorageLive(_28);
--         StorageLive(_29);
--         _29 = _1;
--         StorageLive(_30);
--         _30 = _1;
+          StorageLive(_29);
+          _29 = _1;
+          StorageLive(_30);
+          _30 = _1;
 -         _28 = Ne(move _29, move _30);
--         StorageDead(_30);
--         StorageDead(_29);
 +         _28 = Ne(_1, _1);
+          StorageDead(_30);
+          StorageDead(_29);
           _27 = opaque::<bool>(move _28) -> [return: bb9, unwind unreachable];
       }
   
diff --git a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff
index 36c26dc6605..28664cb0ac8 100644
--- a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff
@@ -37,11 +37,11 @@
       bb0: {
           StorageLive(_2);
           StorageLive(_3);
--         StorageLive(_4);
--         _4 = _1;
+          StorageLive(_4);
+          _4 = _1;
 -         _3 = Add(move _4, const 0f64);
--         StorageDead(_4);
 +         _3 = Add(_1, const 0f64);
+          StorageDead(_4);
           _2 = opaque::<f64>(move _3) -> [return: bb1, unwind continue];
       }
   
@@ -50,11 +50,11 @@
           StorageDead(_2);
           StorageLive(_5);
           StorageLive(_6);
--         StorageLive(_7);
--         _7 = _1;
+          StorageLive(_7);
+          _7 = _1;
 -         _6 = Sub(move _7, const 0f64);
--         StorageDead(_7);
 +         _6 = Sub(_1, const 0f64);
+          StorageDead(_7);
           _5 = opaque::<f64>(move _6) -> [return: bb2, unwind continue];
       }
   
@@ -63,11 +63,11 @@
           StorageDead(_5);
           StorageLive(_8);
           StorageLive(_9);
--         StorageLive(_10);
--         _10 = _1;
+          StorageLive(_10);
+          _10 = _1;
 -         _9 = Mul(move _10, const 0f64);
--         StorageDead(_10);
 +         _9 = Mul(_1, const 0f64);
+          StorageDead(_10);
           _8 = opaque::<f64>(move _9) -> [return: bb3, unwind continue];
       }
   
@@ -76,11 +76,11 @@
           StorageDead(_8);
           StorageLive(_11);
           StorageLive(_12);
--         StorageLive(_13);
--         _13 = _1;
+          StorageLive(_13);
+          _13 = _1;
 -         _12 = Div(move _13, const 0f64);
--         StorageDead(_13);
 +         _12 = Div(_1, const 0f64);
+          StorageDead(_13);
           _11 = opaque::<f64>(move _12) -> [return: bb4, unwind continue];
       }
   
@@ -89,11 +89,11 @@
           StorageDead(_11);
           StorageLive(_14);
           StorageLive(_15);
--         StorageLive(_16);
--         _16 = _1;
+          StorageLive(_16);
+          _16 = _1;
 -         _15 = Div(const 0f64, move _16);
--         StorageDead(_16);
 +         _15 = Div(const 0f64, _1);
+          StorageDead(_16);
           _14 = opaque::<f64>(move _15) -> [return: bb5, unwind continue];
       }
   
@@ -102,11 +102,11 @@
           StorageDead(_14);
           StorageLive(_17);
           StorageLive(_18);
--         StorageLive(_19);
--         _19 = _1;
+          StorageLive(_19);
+          _19 = _1;
 -         _18 = Rem(move _19, const 0f64);
--         StorageDead(_19);
 +         _18 = Rem(_1, const 0f64);
+          StorageDead(_19);
           _17 = opaque::<f64>(move _18) -> [return: bb6, unwind continue];
       }
   
@@ -115,11 +115,11 @@
           StorageDead(_17);
           StorageLive(_20);
           StorageLive(_21);
--         StorageLive(_22);
--         _22 = _1;
+          StorageLive(_22);
+          _22 = _1;
 -         _21 = Rem(const 0f64, move _22);
--         StorageDead(_22);
 +         _21 = Rem(const 0f64, _1);
+          StorageDead(_22);
           _20 = opaque::<f64>(move _21) -> [return: bb7, unwind continue];
       }
   
@@ -128,14 +128,14 @@
           StorageDead(_20);
           StorageLive(_23);
           StorageLive(_24);
--         StorageLive(_25);
--         _25 = _1;
--         StorageLive(_26);
--         _26 = _1;
+          StorageLive(_25);
+          _25 = _1;
+          StorageLive(_26);
+          _26 = _1;
 -         _24 = Eq(move _25, move _26);
--         StorageDead(_26);
--         StorageDead(_25);
 +         _24 = Eq(_1, _1);
+          StorageDead(_26);
+          StorageDead(_25);
           _23 = opaque::<bool>(move _24) -> [return: bb8, unwind continue];
       }
   
@@ -144,14 +144,14 @@
           StorageDead(_23);
           StorageLive(_27);
           StorageLive(_28);
--         StorageLive(_29);
--         _29 = _1;
--         StorageLive(_30);
--         _30 = _1;
+          StorageLive(_29);
+          _29 = _1;
+          StorageLive(_30);
+          _30 = _1;
 -         _28 = Ne(move _29, move _30);
--         StorageDead(_30);
--         StorageDead(_29);
 +         _28 = Ne(_1, _1);
+          StorageDead(_30);
+          StorageDead(_29);
           _27 = opaque::<bool>(move _28) -> [return: bb9, unwind continue];
       }
   
diff --git a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff
index 513fe60b65d..d43198c9911 100644
--- a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff
@@ -105,19 +105,24 @@
   
       bb0: {
 -         StorageLive(_1);
++         nop;
           _1 = const 1_i64;
 -         StorageLive(_2);
++         nop;
           _2 = const 1_u64;
 -         StorageLive(_3);
++         nop;
           _3 = const 1f64;
           StorageLive(_4);
           StorageLive(_5);
--         StorageLive(_6);
+          StorageLive(_6);
 -         _6 = _1;
 -         _5 = move _6 as u8 (IntToInt);
--         StorageDead(_6);
-+         _5 = const 1_i64 as u8 (IntToInt);
-          _4 = opaque::<u8>(move _5) -> [return: bb1, unwind unreachable];
++         _6 = const 1_i64;
++         _5 = const 1_u8;
+          StorageDead(_6);
+-         _4 = opaque::<u8>(move _5) -> [return: bb1, unwind unreachable];
++         _4 = opaque::<u8>(const 1_u8) -> [return: bb1, unwind unreachable];
       }
   
       bb1: {
@@ -125,12 +130,14 @@
           StorageDead(_4);
           StorageLive(_7);
           StorageLive(_8);
--         StorageLive(_9);
+          StorageLive(_9);
 -         _9 = _1;
 -         _8 = move _9 as u16 (IntToInt);
--         StorageDead(_9);
-+         _8 = const 1_i64 as u16 (IntToInt);
-          _7 = opaque::<u16>(move _8) -> [return: bb2, unwind unreachable];
++         _9 = const 1_i64;
++         _8 = const 1_u16;
+          StorageDead(_9);
+-         _7 = opaque::<u16>(move _8) -> [return: bb2, unwind unreachable];
++         _7 = opaque::<u16>(const 1_u16) -> [return: bb2, unwind unreachable];
       }
   
       bb2: {
@@ -138,12 +145,14 @@
           StorageDead(_7);
           StorageLive(_10);
           StorageLive(_11);
--         StorageLive(_12);
+          StorageLive(_12);
 -         _12 = _1;
 -         _11 = move _12 as u32 (IntToInt);
--         StorageDead(_12);
-+         _11 = const 1_i64 as u32 (IntToInt);
-          _10 = opaque::<u32>(move _11) -> [return: bb3, unwind unreachable];
++         _12 = const 1_i64;
++         _11 = const 1_u32;
+          StorageDead(_12);
+-         _10 = opaque::<u32>(move _11) -> [return: bb3, unwind unreachable];
++         _10 = opaque::<u32>(const 1_u32) -> [return: bb3, unwind unreachable];
       }
   
       bb3: {
@@ -151,12 +160,14 @@
           StorageDead(_10);
           StorageLive(_13);
           StorageLive(_14);
--         StorageLive(_15);
+          StorageLive(_15);
 -         _15 = _1;
 -         _14 = move _15 as u64 (IntToInt);
--         StorageDead(_15);
-+         _14 = const 1_i64 as u64 (IntToInt);
-          _13 = opaque::<u64>(move _14) -> [return: bb4, unwind unreachable];
++         _15 = const 1_i64;
++         _14 = const 1_u64;
+          StorageDead(_15);
+-         _13 = opaque::<u64>(move _14) -> [return: bb4, unwind unreachable];
++         _13 = opaque::<u64>(const 1_u64) -> [return: bb4, unwind unreachable];
       }
   
       bb4: {
@@ -164,12 +175,14 @@
           StorageDead(_13);
           StorageLive(_16);
           StorageLive(_17);
--         StorageLive(_18);
+          StorageLive(_18);
 -         _18 = _1;
 -         _17 = move _18 as i8 (IntToInt);
--         StorageDead(_18);
-+         _17 = const 1_i64 as i8 (IntToInt);
-          _16 = opaque::<i8>(move _17) -> [return: bb5, unwind unreachable];
++         _18 = const 1_i64;
++         _17 = const 1_i8;
+          StorageDead(_18);
+-         _16 = opaque::<i8>(move _17) -> [return: bb5, unwind unreachable];
++         _16 = opaque::<i8>(const 1_i8) -> [return: bb5, unwind unreachable];
       }
   
       bb5: {
@@ -177,12 +190,14 @@
           StorageDead(_16);
           StorageLive(_19);
           StorageLive(_20);
--         StorageLive(_21);
+          StorageLive(_21);
 -         _21 = _1;
 -         _20 = move _21 as i16 (IntToInt);
--         StorageDead(_21);
-+         _20 = const 1_i64 as i16 (IntToInt);
-          _19 = opaque::<i16>(move _20) -> [return: bb6, unwind unreachable];
++         _21 = const 1_i64;
++         _20 = const 1_i16;
+          StorageDead(_21);
+-         _19 = opaque::<i16>(move _20) -> [return: bb6, unwind unreachable];
++         _19 = opaque::<i16>(const 1_i16) -> [return: bb6, unwind unreachable];
       }
   
       bb6: {
@@ -190,35 +205,40 @@
           StorageDead(_19);
           StorageLive(_22);
           StorageLive(_23);
--         StorageLive(_24);
+          StorageLive(_24);
 -         _24 = _1;
 -         _23 = move _24 as i32 (IntToInt);
--         StorageDead(_24);
-+         _23 = const 1_i64 as i32 (IntToInt);
-          _22 = opaque::<i32>(move _23) -> [return: bb7, unwind unreachable];
++         _24 = const 1_i64;
++         _23 = const 1_i32;
+          StorageDead(_24);
+-         _22 = opaque::<i32>(move _23) -> [return: bb7, unwind unreachable];
++         _22 = opaque::<i32>(const 1_i32) -> [return: bb7, unwind unreachable];
       }
   
       bb7: {
           StorageDead(_23);
           StorageDead(_22);
           StorageLive(_25);
--         StorageLive(_26);
+          StorageLive(_26);
 -         _26 = _1;
 -         _25 = opaque::<i64>(move _26) -> [return: bb8, unwind unreachable];
++         _26 = const 1_i64;
 +         _25 = opaque::<i64>(const 1_i64) -> [return: bb8, unwind unreachable];
       }
   
       bb8: {
--         StorageDead(_26);
+          StorageDead(_26);
           StorageDead(_25);
           StorageLive(_27);
           StorageLive(_28);
--         StorageLive(_29);
+          StorageLive(_29);
 -         _29 = _1;
 -         _28 = move _29 as f32 (IntToFloat);
--         StorageDead(_29);
-+         _28 = const 1_i64 as f32 (IntToFloat);
-          _27 = opaque::<f32>(move _28) -> [return: bb9, unwind unreachable];
++         _29 = const 1_i64;
++         _28 = const 1f32;
+          StorageDead(_29);
+-         _27 = opaque::<f32>(move _28) -> [return: bb9, unwind unreachable];
++         _27 = opaque::<f32>(const 1f32) -> [return: bb9, unwind unreachable];
       }
   
       bb9: {
@@ -226,12 +246,14 @@
           StorageDead(_27);
           StorageLive(_30);
           StorageLive(_31);
--         StorageLive(_32);
+          StorageLive(_32);
 -         _32 = _1;
 -         _31 = move _32 as f64 (IntToFloat);
--         StorageDead(_32);
-+         _31 = const 1_i64 as f64 (IntToFloat);
-          _30 = opaque::<f64>(move _31) -> [return: bb10, unwind unreachable];
++         _32 = const 1_i64;
++         _31 = const 1f64;
+          StorageDead(_32);
+-         _30 = opaque::<f64>(move _31) -> [return: bb10, unwind unreachable];
++         _30 = opaque::<f64>(const 1f64) -> [return: bb10, unwind unreachable];
       }
   
       bb10: {
@@ -239,12 +261,14 @@
           StorageDead(_30);
           StorageLive(_33);
           StorageLive(_34);
--         StorageLive(_35);
+          StorageLive(_35);
 -         _35 = _2;
 -         _34 = move _35 as u8 (IntToInt);
--         StorageDead(_35);
-+         _34 = const 1_u64 as u8 (IntToInt);
-          _33 = opaque::<u8>(move _34) -> [return: bb11, unwind unreachable];
++         _35 = const 1_u64;
++         _34 = const 1_u8;
+          StorageDead(_35);
+-         _33 = opaque::<u8>(move _34) -> [return: bb11, unwind unreachable];
++         _33 = opaque::<u8>(const 1_u8) -> [return: bb11, unwind unreachable];
       }
   
       bb11: {
@@ -252,12 +276,14 @@
           StorageDead(_33);
           StorageLive(_36);
           StorageLive(_37);
--         StorageLive(_38);
+          StorageLive(_38);
 -         _38 = _2;
 -         _37 = move _38 as u16 (IntToInt);
--         StorageDead(_38);
-+         _37 = const 1_u64 as u16 (IntToInt);
-          _36 = opaque::<u16>(move _37) -> [return: bb12, unwind unreachable];
++         _38 = const 1_u64;
++         _37 = const 1_u16;
+          StorageDead(_38);
+-         _36 = opaque::<u16>(move _37) -> [return: bb12, unwind unreachable];
++         _36 = opaque::<u16>(const 1_u16) -> [return: bb12, unwind unreachable];
       }
   
       bb12: {
@@ -265,35 +291,40 @@
           StorageDead(_36);
           StorageLive(_39);
           StorageLive(_40);
--         StorageLive(_41);
+          StorageLive(_41);
 -         _41 = _2;
 -         _40 = move _41 as u32 (IntToInt);
--         StorageDead(_41);
-+         _40 = const 1_u64 as u32 (IntToInt);
-          _39 = opaque::<u32>(move _40) -> [return: bb13, unwind unreachable];
++         _41 = const 1_u64;
++         _40 = const 1_u32;
+          StorageDead(_41);
+-         _39 = opaque::<u32>(move _40) -> [return: bb13, unwind unreachable];
++         _39 = opaque::<u32>(const 1_u32) -> [return: bb13, unwind unreachable];
       }
   
       bb13: {
           StorageDead(_40);
           StorageDead(_39);
           StorageLive(_42);
--         StorageLive(_43);
+          StorageLive(_43);
 -         _43 = _2;
 -         _42 = opaque::<u64>(move _43) -> [return: bb14, unwind unreachable];
++         _43 = const 1_u64;
 +         _42 = opaque::<u64>(const 1_u64) -> [return: bb14, unwind unreachable];
       }
   
       bb14: {
--         StorageDead(_43);
+          StorageDead(_43);
           StorageDead(_42);
           StorageLive(_44);
           StorageLive(_45);
--         StorageLive(_46);
+          StorageLive(_46);
 -         _46 = _2;
 -         _45 = move _46 as i8 (IntToInt);
--         StorageDead(_46);
-+         _45 = const 1_u64 as i8 (IntToInt);
-          _44 = opaque::<i8>(move _45) -> [return: bb15, unwind unreachable];
++         _46 = const 1_u64;
++         _45 = const 1_i8;
+          StorageDead(_46);
+-         _44 = opaque::<i8>(move _45) -> [return: bb15, unwind unreachable];
++         _44 = opaque::<i8>(const 1_i8) -> [return: bb15, unwind unreachable];
       }
   
       bb15: {
@@ -301,12 +332,14 @@
           StorageDead(_44);
           StorageLive(_47);
           StorageLive(_48);
--         StorageLive(_49);
+          StorageLive(_49);
 -         _49 = _2;
 -         _48 = move _49 as i16 (IntToInt);
--         StorageDead(_49);
-+         _48 = const 1_u64 as i16 (IntToInt);
-          _47 = opaque::<i16>(move _48) -> [return: bb16, unwind unreachable];
++         _49 = const 1_u64;
++         _48 = const 1_i16;
+          StorageDead(_49);
+-         _47 = opaque::<i16>(move _48) -> [return: bb16, unwind unreachable];
++         _47 = opaque::<i16>(const 1_i16) -> [return: bb16, unwind unreachable];
       }
   
       bb16: {
@@ -314,12 +347,14 @@
           StorageDead(_47);
           StorageLive(_50);
           StorageLive(_51);
--         StorageLive(_52);
+          StorageLive(_52);
 -         _52 = _2;
 -         _51 = move _52 as i32 (IntToInt);
--         StorageDead(_52);
-+         _51 = const 1_u64 as i32 (IntToInt);
-          _50 = opaque::<i32>(move _51) -> [return: bb17, unwind unreachable];
++         _52 = const 1_u64;
++         _51 = const 1_i32;
+          StorageDead(_52);
+-         _50 = opaque::<i32>(move _51) -> [return: bb17, unwind unreachable];
++         _50 = opaque::<i32>(const 1_i32) -> [return: bb17, unwind unreachable];
       }
   
       bb17: {
@@ -327,12 +362,14 @@
           StorageDead(_50);
           StorageLive(_53);
           StorageLive(_54);
--         StorageLive(_55);
+          StorageLive(_55);
 -         _55 = _2;
 -         _54 = move _55 as i64 (IntToInt);
--         StorageDead(_55);
-+         _54 = const 1_u64 as i64 (IntToInt);
-          _53 = opaque::<i64>(move _54) -> [return: bb18, unwind unreachable];
++         _55 = const 1_u64;
++         _54 = const 1_i64;
+          StorageDead(_55);
+-         _53 = opaque::<i64>(move _54) -> [return: bb18, unwind unreachable];
++         _53 = opaque::<i64>(const 1_i64) -> [return: bb18, unwind unreachable];
       }
   
       bb18: {
@@ -340,12 +377,14 @@
           StorageDead(_53);
           StorageLive(_56);
           StorageLive(_57);
--         StorageLive(_58);
+          StorageLive(_58);
 -         _58 = _2;
 -         _57 = move _58 as f32 (IntToFloat);
--         StorageDead(_58);
-+         _57 = const 1_u64 as f32 (IntToFloat);
-          _56 = opaque::<f32>(move _57) -> [return: bb19, unwind unreachable];
++         _58 = const 1_u64;
++         _57 = const 1f32;
+          StorageDead(_58);
+-         _56 = opaque::<f32>(move _57) -> [return: bb19, unwind unreachable];
++         _56 = opaque::<f32>(const 1f32) -> [return: bb19, unwind unreachable];
       }
   
       bb19: {
@@ -353,12 +392,14 @@
           StorageDead(_56);
           StorageLive(_59);
           StorageLive(_60);
--         StorageLive(_61);
+          StorageLive(_61);
 -         _61 = _2;
 -         _60 = move _61 as f64 (IntToFloat);
--         StorageDead(_61);
-+         _60 = const 1_u64 as f64 (IntToFloat);
-          _59 = opaque::<f64>(move _60) -> [return: bb20, unwind unreachable];
++         _61 = const 1_u64;
++         _60 = const 1f64;
+          StorageDead(_61);
+-         _59 = opaque::<f64>(move _60) -> [return: bb20, unwind unreachable];
++         _59 = opaque::<f64>(const 1f64) -> [return: bb20, unwind unreachable];
       }
   
       bb20: {
@@ -366,12 +407,14 @@
           StorageDead(_59);
           StorageLive(_62);
           StorageLive(_63);
--         StorageLive(_64);
+          StorageLive(_64);
 -         _64 = _3;
 -         _63 = move _64 as u8 (FloatToInt);
--         StorageDead(_64);
-+         _63 = const 1f64 as u8 (FloatToInt);
-          _62 = opaque::<u8>(move _63) -> [return: bb21, unwind unreachable];
++         _64 = const 1f64;
++         _63 = const 1_u8;
+          StorageDead(_64);
+-         _62 = opaque::<u8>(move _63) -> [return: bb21, unwind unreachable];
++         _62 = opaque::<u8>(const 1_u8) -> [return: bb21, unwind unreachable];
       }
   
       bb21: {
@@ -379,12 +422,14 @@
           StorageDead(_62);
           StorageLive(_65);
           StorageLive(_66);
--         StorageLive(_67);
+          StorageLive(_67);
 -         _67 = _3;
 -         _66 = move _67 as u16 (FloatToInt);
--         StorageDead(_67);
-+         _66 = const 1f64 as u16 (FloatToInt);
-          _65 = opaque::<u16>(move _66) -> [return: bb22, unwind unreachable];
++         _67 = const 1f64;
++         _66 = const 1_u16;
+          StorageDead(_67);
+-         _65 = opaque::<u16>(move _66) -> [return: bb22, unwind unreachable];
++         _65 = opaque::<u16>(const 1_u16) -> [return: bb22, unwind unreachable];
       }
   
       bb22: {
@@ -392,12 +437,14 @@
           StorageDead(_65);
           StorageLive(_68);
           StorageLive(_69);
--         StorageLive(_70);
+          StorageLive(_70);
 -         _70 = _3;
 -         _69 = move _70 as u32 (FloatToInt);
--         StorageDead(_70);
-+         _69 = const 1f64 as u32 (FloatToInt);
-          _68 = opaque::<u32>(move _69) -> [return: bb23, unwind unreachable];
++         _70 = const 1f64;
++         _69 = const 1_u32;
+          StorageDead(_70);
+-         _68 = opaque::<u32>(move _69) -> [return: bb23, unwind unreachable];
++         _68 = opaque::<u32>(const 1_u32) -> [return: bb23, unwind unreachable];
       }
   
       bb23: {
@@ -405,12 +452,14 @@
           StorageDead(_68);
           StorageLive(_71);
           StorageLive(_72);
--         StorageLive(_73);
+          StorageLive(_73);
 -         _73 = _3;
 -         _72 = move _73 as u64 (FloatToInt);
--         StorageDead(_73);
-+         _72 = const 1f64 as u64 (FloatToInt);
-          _71 = opaque::<u64>(move _72) -> [return: bb24, unwind unreachable];
++         _73 = const 1f64;
++         _72 = const 1_u64;
+          StorageDead(_73);
+-         _71 = opaque::<u64>(move _72) -> [return: bb24, unwind unreachable];
++         _71 = opaque::<u64>(const 1_u64) -> [return: bb24, unwind unreachable];
       }
   
       bb24: {
@@ -418,12 +467,14 @@
           StorageDead(_71);
           StorageLive(_74);
           StorageLive(_75);
--         StorageLive(_76);
+          StorageLive(_76);
 -         _76 = _3;
 -         _75 = move _76 as i8 (FloatToInt);
--         StorageDead(_76);
-+         _75 = const 1f64 as i8 (FloatToInt);
-          _74 = opaque::<i8>(move _75) -> [return: bb25, unwind unreachable];
++         _76 = const 1f64;
++         _75 = const 1_i8;
+          StorageDead(_76);
+-         _74 = opaque::<i8>(move _75) -> [return: bb25, unwind unreachable];
++         _74 = opaque::<i8>(const 1_i8) -> [return: bb25, unwind unreachable];
       }
   
       bb25: {
@@ -431,12 +482,14 @@
           StorageDead(_74);
           StorageLive(_77);
           StorageLive(_78);
--         StorageLive(_79);
+          StorageLive(_79);
 -         _79 = _3;
 -         _78 = move _79 as i16 (FloatToInt);
--         StorageDead(_79);
-+         _78 = const 1f64 as i16 (FloatToInt);
-          _77 = opaque::<i16>(move _78) -> [return: bb26, unwind unreachable];
++         _79 = const 1f64;
++         _78 = const 1_i16;
+          StorageDead(_79);
+-         _77 = opaque::<i16>(move _78) -> [return: bb26, unwind unreachable];
++         _77 = opaque::<i16>(const 1_i16) -> [return: bb26, unwind unreachable];
       }
   
       bb26: {
@@ -444,12 +497,14 @@
           StorageDead(_77);
           StorageLive(_80);
           StorageLive(_81);
--         StorageLive(_82);
+          StorageLive(_82);
 -         _82 = _3;
 -         _81 = move _82 as i32 (FloatToInt);
--         StorageDead(_82);
-+         _81 = const 1f64 as i32 (FloatToInt);
-          _80 = opaque::<i32>(move _81) -> [return: bb27, unwind unreachable];
++         _82 = const 1f64;
++         _81 = const 1_i32;
+          StorageDead(_82);
+-         _80 = opaque::<i32>(move _81) -> [return: bb27, unwind unreachable];
++         _80 = opaque::<i32>(const 1_i32) -> [return: bb27, unwind unreachable];
       }
   
       bb27: {
@@ -457,12 +512,14 @@
           StorageDead(_80);
           StorageLive(_83);
           StorageLive(_84);
--         StorageLive(_85);
+          StorageLive(_85);
 -         _85 = _3;
 -         _84 = move _85 as i64 (FloatToInt);
--         StorageDead(_85);
-+         _84 = const 1f64 as i64 (FloatToInt);
-          _83 = opaque::<i64>(move _84) -> [return: bb28, unwind unreachable];
++         _85 = const 1f64;
++         _84 = const 1_i64;
+          StorageDead(_85);
+-         _83 = opaque::<i64>(move _84) -> [return: bb28, unwind unreachable];
++         _83 = opaque::<i64>(const 1_i64) -> [return: bb28, unwind unreachable];
       }
   
       bb28: {
@@ -470,31 +527,37 @@
           StorageDead(_83);
           StorageLive(_86);
           StorageLive(_87);
--         StorageLive(_88);
+          StorageLive(_88);
 -         _88 = _3;
 -         _87 = move _88 as f32 (FloatToFloat);
--         StorageDead(_88);
-+         _87 = const 1f64 as f32 (FloatToFloat);
-          _86 = opaque::<f32>(move _87) -> [return: bb29, unwind unreachable];
++         _88 = const 1f64;
++         _87 = const 1f32;
+          StorageDead(_88);
+-         _86 = opaque::<f32>(move _87) -> [return: bb29, unwind unreachable];
++         _86 = opaque::<f32>(const 1f32) -> [return: bb29, unwind unreachable];
       }
   
       bb29: {
           StorageDead(_87);
           StorageDead(_86);
           StorageLive(_89);
--         StorageLive(_90);
+          StorageLive(_90);
 -         _90 = _3;
 -         _89 = opaque::<f64>(move _90) -> [return: bb30, unwind unreachable];
++         _90 = const 1f64;
 +         _89 = opaque::<f64>(const 1f64) -> [return: bb30, unwind unreachable];
       }
   
       bb30: {
--         StorageDead(_90);
+          StorageDead(_90);
           StorageDead(_89);
           _0 = const ();
 -         StorageDead(_3);
 -         StorageDead(_2);
 -         StorageDead(_1);
++         nop;
++         nop;
++         nop;
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff
index 33192ed8de0..08b97e13aa0 100644
--- a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff
@@ -105,19 +105,24 @@
   
       bb0: {
 -         StorageLive(_1);
++         nop;
           _1 = const 1_i64;
 -         StorageLive(_2);
++         nop;
           _2 = const 1_u64;
 -         StorageLive(_3);
++         nop;
           _3 = const 1f64;
           StorageLive(_4);
           StorageLive(_5);
--         StorageLive(_6);
+          StorageLive(_6);
 -         _6 = _1;
 -         _5 = move _6 as u8 (IntToInt);
--         StorageDead(_6);
-+         _5 = const 1_i64 as u8 (IntToInt);
-          _4 = opaque::<u8>(move _5) -> [return: bb1, unwind continue];
++         _6 = const 1_i64;
++         _5 = const 1_u8;
+          StorageDead(_6);
+-         _4 = opaque::<u8>(move _5) -> [return: bb1, unwind continue];
++         _4 = opaque::<u8>(const 1_u8) -> [return: bb1, unwind continue];
       }
   
       bb1: {
@@ -125,12 +130,14 @@
           StorageDead(_4);
           StorageLive(_7);
           StorageLive(_8);
--         StorageLive(_9);
+          StorageLive(_9);
 -         _9 = _1;
 -         _8 = move _9 as u16 (IntToInt);
--         StorageDead(_9);
-+         _8 = const 1_i64 as u16 (IntToInt);
-          _7 = opaque::<u16>(move _8) -> [return: bb2, unwind continue];
++         _9 = const 1_i64;
++         _8 = const 1_u16;
+          StorageDead(_9);
+-         _7 = opaque::<u16>(move _8) -> [return: bb2, unwind continue];
++         _7 = opaque::<u16>(const 1_u16) -> [return: bb2, unwind continue];
       }
   
       bb2: {
@@ -138,12 +145,14 @@
           StorageDead(_7);
           StorageLive(_10);
           StorageLive(_11);
--         StorageLive(_12);
+          StorageLive(_12);
 -         _12 = _1;
 -         _11 = move _12 as u32 (IntToInt);
--         StorageDead(_12);
-+         _11 = const 1_i64 as u32 (IntToInt);
-          _10 = opaque::<u32>(move _11) -> [return: bb3, unwind continue];
++         _12 = const 1_i64;
++         _11 = const 1_u32;
+          StorageDead(_12);
+-         _10 = opaque::<u32>(move _11) -> [return: bb3, unwind continue];
++         _10 = opaque::<u32>(const 1_u32) -> [return: bb3, unwind continue];
       }
   
       bb3: {
@@ -151,12 +160,14 @@
           StorageDead(_10);
           StorageLive(_13);
           StorageLive(_14);
--         StorageLive(_15);
+          StorageLive(_15);
 -         _15 = _1;
 -         _14 = move _15 as u64 (IntToInt);
--         StorageDead(_15);
-+         _14 = const 1_i64 as u64 (IntToInt);
-          _13 = opaque::<u64>(move _14) -> [return: bb4, unwind continue];
++         _15 = const 1_i64;
++         _14 = const 1_u64;
+          StorageDead(_15);
+-         _13 = opaque::<u64>(move _14) -> [return: bb4, unwind continue];
++         _13 = opaque::<u64>(const 1_u64) -> [return: bb4, unwind continue];
       }
   
       bb4: {
@@ -164,12 +175,14 @@
           StorageDead(_13);
           StorageLive(_16);
           StorageLive(_17);
--         StorageLive(_18);
+          StorageLive(_18);
 -         _18 = _1;
 -         _17 = move _18 as i8 (IntToInt);
--         StorageDead(_18);
-+         _17 = const 1_i64 as i8 (IntToInt);
-          _16 = opaque::<i8>(move _17) -> [return: bb5, unwind continue];
++         _18 = const 1_i64;
++         _17 = const 1_i8;
+          StorageDead(_18);
+-         _16 = opaque::<i8>(move _17) -> [return: bb5, unwind continue];
++         _16 = opaque::<i8>(const 1_i8) -> [return: bb5, unwind continue];
       }
   
       bb5: {
@@ -177,12 +190,14 @@
           StorageDead(_16);
           StorageLive(_19);
           StorageLive(_20);
--         StorageLive(_21);
+          StorageLive(_21);
 -         _21 = _1;
 -         _20 = move _21 as i16 (IntToInt);
--         StorageDead(_21);
-+         _20 = const 1_i64 as i16 (IntToInt);
-          _19 = opaque::<i16>(move _20) -> [return: bb6, unwind continue];
++         _21 = const 1_i64;
++         _20 = const 1_i16;
+          StorageDead(_21);
+-         _19 = opaque::<i16>(move _20) -> [return: bb6, unwind continue];
++         _19 = opaque::<i16>(const 1_i16) -> [return: bb6, unwind continue];
       }
   
       bb6: {
@@ -190,35 +205,40 @@
           StorageDead(_19);
           StorageLive(_22);
           StorageLive(_23);
--         StorageLive(_24);
+          StorageLive(_24);
 -         _24 = _1;
 -         _23 = move _24 as i32 (IntToInt);
--         StorageDead(_24);
-+         _23 = const 1_i64 as i32 (IntToInt);
-          _22 = opaque::<i32>(move _23) -> [return: bb7, unwind continue];
++         _24 = const 1_i64;
++         _23 = const 1_i32;
+          StorageDead(_24);
+-         _22 = opaque::<i32>(move _23) -> [return: bb7, unwind continue];
++         _22 = opaque::<i32>(const 1_i32) -> [return: bb7, unwind continue];
       }
   
       bb7: {
           StorageDead(_23);
           StorageDead(_22);
           StorageLive(_25);
--         StorageLive(_26);
+          StorageLive(_26);
 -         _26 = _1;
 -         _25 = opaque::<i64>(move _26) -> [return: bb8, unwind continue];
++         _26 = const 1_i64;
 +         _25 = opaque::<i64>(const 1_i64) -> [return: bb8, unwind continue];
       }
   
       bb8: {
--         StorageDead(_26);
+          StorageDead(_26);
           StorageDead(_25);
           StorageLive(_27);
           StorageLive(_28);
--         StorageLive(_29);
+          StorageLive(_29);
 -         _29 = _1;
 -         _28 = move _29 as f32 (IntToFloat);
--         StorageDead(_29);
-+         _28 = const 1_i64 as f32 (IntToFloat);
-          _27 = opaque::<f32>(move _28) -> [return: bb9, unwind continue];
++         _29 = const 1_i64;
++         _28 = const 1f32;
+          StorageDead(_29);
+-         _27 = opaque::<f32>(move _28) -> [return: bb9, unwind continue];
++         _27 = opaque::<f32>(const 1f32) -> [return: bb9, unwind continue];
       }
   
       bb9: {
@@ -226,12 +246,14 @@
           StorageDead(_27);
           StorageLive(_30);
           StorageLive(_31);
--         StorageLive(_32);
+          StorageLive(_32);
 -         _32 = _1;
 -         _31 = move _32 as f64 (IntToFloat);
--         StorageDead(_32);
-+         _31 = const 1_i64 as f64 (IntToFloat);
-          _30 = opaque::<f64>(move _31) -> [return: bb10, unwind continue];
++         _32 = const 1_i64;
++         _31 = const 1f64;
+          StorageDead(_32);
+-         _30 = opaque::<f64>(move _31) -> [return: bb10, unwind continue];
++         _30 = opaque::<f64>(const 1f64) -> [return: bb10, unwind continue];
       }
   
       bb10: {
@@ -239,12 +261,14 @@
           StorageDead(_30);
           StorageLive(_33);
           StorageLive(_34);
--         StorageLive(_35);
+          StorageLive(_35);
 -         _35 = _2;
 -         _34 = move _35 as u8 (IntToInt);
--         StorageDead(_35);
-+         _34 = const 1_u64 as u8 (IntToInt);
-          _33 = opaque::<u8>(move _34) -> [return: bb11, unwind continue];
++         _35 = const 1_u64;
++         _34 = const 1_u8;
+          StorageDead(_35);
+-         _33 = opaque::<u8>(move _34) -> [return: bb11, unwind continue];
++         _33 = opaque::<u8>(const 1_u8) -> [return: bb11, unwind continue];
       }
   
       bb11: {
@@ -252,12 +276,14 @@
           StorageDead(_33);
           StorageLive(_36);
           StorageLive(_37);
--         StorageLive(_38);
+          StorageLive(_38);
 -         _38 = _2;
 -         _37 = move _38 as u16 (IntToInt);
--         StorageDead(_38);
-+         _37 = const 1_u64 as u16 (IntToInt);
-          _36 = opaque::<u16>(move _37) -> [return: bb12, unwind continue];
++         _38 = const 1_u64;
++         _37 = const 1_u16;
+          StorageDead(_38);
+-         _36 = opaque::<u16>(move _37) -> [return: bb12, unwind continue];
++         _36 = opaque::<u16>(const 1_u16) -> [return: bb12, unwind continue];
       }
   
       bb12: {
@@ -265,35 +291,40 @@
           StorageDead(_36);
           StorageLive(_39);
           StorageLive(_40);
--         StorageLive(_41);
+          StorageLive(_41);
 -         _41 = _2;
 -         _40 = move _41 as u32 (IntToInt);
--         StorageDead(_41);
-+         _40 = const 1_u64 as u32 (IntToInt);
-          _39 = opaque::<u32>(move _40) -> [return: bb13, unwind continue];
++         _41 = const 1_u64;
++         _40 = const 1_u32;
+          StorageDead(_41);
+-         _39 = opaque::<u32>(move _40) -> [return: bb13, unwind continue];
++         _39 = opaque::<u32>(const 1_u32) -> [return: bb13, unwind continue];
       }
   
       bb13: {
           StorageDead(_40);
           StorageDead(_39);
           StorageLive(_42);
--         StorageLive(_43);
+          StorageLive(_43);
 -         _43 = _2;
 -         _42 = opaque::<u64>(move _43) -> [return: bb14, unwind continue];
++         _43 = const 1_u64;
 +         _42 = opaque::<u64>(const 1_u64) -> [return: bb14, unwind continue];
       }
   
       bb14: {
--         StorageDead(_43);
+          StorageDead(_43);
           StorageDead(_42);
           StorageLive(_44);
           StorageLive(_45);
--         StorageLive(_46);
+          StorageLive(_46);
 -         _46 = _2;
 -         _45 = move _46 as i8 (IntToInt);
--         StorageDead(_46);
-+         _45 = const 1_u64 as i8 (IntToInt);
-          _44 = opaque::<i8>(move _45) -> [return: bb15, unwind continue];
++         _46 = const 1_u64;
++         _45 = const 1_i8;
+          StorageDead(_46);
+-         _44 = opaque::<i8>(move _45) -> [return: bb15, unwind continue];
++         _44 = opaque::<i8>(const 1_i8) -> [return: bb15, unwind continue];
       }
   
       bb15: {
@@ -301,12 +332,14 @@
           StorageDead(_44);
           StorageLive(_47);
           StorageLive(_48);
--         StorageLive(_49);
+          StorageLive(_49);
 -         _49 = _2;
 -         _48 = move _49 as i16 (IntToInt);
--         StorageDead(_49);
-+         _48 = const 1_u64 as i16 (IntToInt);
-          _47 = opaque::<i16>(move _48) -> [return: bb16, unwind continue];
++         _49 = const 1_u64;
++         _48 = const 1_i16;
+          StorageDead(_49);
+-         _47 = opaque::<i16>(move _48) -> [return: bb16, unwind continue];
++         _47 = opaque::<i16>(const 1_i16) -> [return: bb16, unwind continue];
       }
   
       bb16: {
@@ -314,12 +347,14 @@
           StorageDead(_47);
           StorageLive(_50);
           StorageLive(_51);
--         StorageLive(_52);
+          StorageLive(_52);
 -         _52 = _2;
 -         _51 = move _52 as i32 (IntToInt);
--         StorageDead(_52);
-+         _51 = const 1_u64 as i32 (IntToInt);
-          _50 = opaque::<i32>(move _51) -> [return: bb17, unwind continue];
++         _52 = const 1_u64;
++         _51 = const 1_i32;
+          StorageDead(_52);
+-         _50 = opaque::<i32>(move _51) -> [return: bb17, unwind continue];
++         _50 = opaque::<i32>(const 1_i32) -> [return: bb17, unwind continue];
       }
   
       bb17: {
@@ -327,12 +362,14 @@
           StorageDead(_50);
           StorageLive(_53);
           StorageLive(_54);
--         StorageLive(_55);
+          StorageLive(_55);
 -         _55 = _2;
 -         _54 = move _55 as i64 (IntToInt);
--         StorageDead(_55);
-+         _54 = const 1_u64 as i64 (IntToInt);
-          _53 = opaque::<i64>(move _54) -> [return: bb18, unwind continue];
++         _55 = const 1_u64;
++         _54 = const 1_i64;
+          StorageDead(_55);
+-         _53 = opaque::<i64>(move _54) -> [return: bb18, unwind continue];
++         _53 = opaque::<i64>(const 1_i64) -> [return: bb18, unwind continue];
       }
   
       bb18: {
@@ -340,12 +377,14 @@
           StorageDead(_53);
           StorageLive(_56);
           StorageLive(_57);
--         StorageLive(_58);
+          StorageLive(_58);
 -         _58 = _2;
 -         _57 = move _58 as f32 (IntToFloat);
--         StorageDead(_58);
-+         _57 = const 1_u64 as f32 (IntToFloat);
-          _56 = opaque::<f32>(move _57) -> [return: bb19, unwind continue];
++         _58 = const 1_u64;
++         _57 = const 1f32;
+          StorageDead(_58);
+-         _56 = opaque::<f32>(move _57) -> [return: bb19, unwind continue];
++         _56 = opaque::<f32>(const 1f32) -> [return: bb19, unwind continue];
       }
   
       bb19: {
@@ -353,12 +392,14 @@
           StorageDead(_56);
           StorageLive(_59);
           StorageLive(_60);
--         StorageLive(_61);
+          StorageLive(_61);
 -         _61 = _2;
 -         _60 = move _61 as f64 (IntToFloat);
--         StorageDead(_61);
-+         _60 = const 1_u64 as f64 (IntToFloat);
-          _59 = opaque::<f64>(move _60) -> [return: bb20, unwind continue];
++         _61 = const 1_u64;
++         _60 = const 1f64;
+          StorageDead(_61);
+-         _59 = opaque::<f64>(move _60) -> [return: bb20, unwind continue];
++         _59 = opaque::<f64>(const 1f64) -> [return: bb20, unwind continue];
       }
   
       bb20: {
@@ -366,12 +407,14 @@
           StorageDead(_59);
           StorageLive(_62);
           StorageLive(_63);
--         StorageLive(_64);
+          StorageLive(_64);
 -         _64 = _3;
 -         _63 = move _64 as u8 (FloatToInt);
--         StorageDead(_64);
-+         _63 = const 1f64 as u8 (FloatToInt);
-          _62 = opaque::<u8>(move _63) -> [return: bb21, unwind continue];
++         _64 = const 1f64;
++         _63 = const 1_u8;
+          StorageDead(_64);
+-         _62 = opaque::<u8>(move _63) -> [return: bb21, unwind continue];
++         _62 = opaque::<u8>(const 1_u8) -> [return: bb21, unwind continue];
       }
   
       bb21: {
@@ -379,12 +422,14 @@
           StorageDead(_62);
           StorageLive(_65);
           StorageLive(_66);
--         StorageLive(_67);
+          StorageLive(_67);
 -         _67 = _3;
 -         _66 = move _67 as u16 (FloatToInt);
--         StorageDead(_67);
-+         _66 = const 1f64 as u16 (FloatToInt);
-          _65 = opaque::<u16>(move _66) -> [return: bb22, unwind continue];
++         _67 = const 1f64;
++         _66 = const 1_u16;
+          StorageDead(_67);
+-         _65 = opaque::<u16>(move _66) -> [return: bb22, unwind continue];
++         _65 = opaque::<u16>(const 1_u16) -> [return: bb22, unwind continue];
       }
   
       bb22: {
@@ -392,12 +437,14 @@
           StorageDead(_65);
           StorageLive(_68);
           StorageLive(_69);
--         StorageLive(_70);
+          StorageLive(_70);
 -         _70 = _3;
 -         _69 = move _70 as u32 (FloatToInt);
--         StorageDead(_70);
-+         _69 = const 1f64 as u32 (FloatToInt);
-          _68 = opaque::<u32>(move _69) -> [return: bb23, unwind continue];
++         _70 = const 1f64;
++         _69 = const 1_u32;
+          StorageDead(_70);
+-         _68 = opaque::<u32>(move _69) -> [return: bb23, unwind continue];
++         _68 = opaque::<u32>(const 1_u32) -> [return: bb23, unwind continue];
       }
   
       bb23: {
@@ -405,12 +452,14 @@
           StorageDead(_68);
           StorageLive(_71);
           StorageLive(_72);
--         StorageLive(_73);
+          StorageLive(_73);
 -         _73 = _3;
 -         _72 = move _73 as u64 (FloatToInt);
--         StorageDead(_73);
-+         _72 = const 1f64 as u64 (FloatToInt);
-          _71 = opaque::<u64>(move _72) -> [return: bb24, unwind continue];
++         _73 = const 1f64;
++         _72 = const 1_u64;
+          StorageDead(_73);
+-         _71 = opaque::<u64>(move _72) -> [return: bb24, unwind continue];
++         _71 = opaque::<u64>(const 1_u64) -> [return: bb24, unwind continue];
       }
   
       bb24: {
@@ -418,12 +467,14 @@
           StorageDead(_71);
           StorageLive(_74);
           StorageLive(_75);
--         StorageLive(_76);
+          StorageLive(_76);
 -         _76 = _3;
 -         _75 = move _76 as i8 (FloatToInt);
--         StorageDead(_76);
-+         _75 = const 1f64 as i8 (FloatToInt);
-          _74 = opaque::<i8>(move _75) -> [return: bb25, unwind continue];
++         _76 = const 1f64;
++         _75 = const 1_i8;
+          StorageDead(_76);
+-         _74 = opaque::<i8>(move _75) -> [return: bb25, unwind continue];
++         _74 = opaque::<i8>(const 1_i8) -> [return: bb25, unwind continue];
       }
   
       bb25: {
@@ -431,12 +482,14 @@
           StorageDead(_74);
           StorageLive(_77);
           StorageLive(_78);
--         StorageLive(_79);
+          StorageLive(_79);
 -         _79 = _3;
 -         _78 = move _79 as i16 (FloatToInt);
--         StorageDead(_79);
-+         _78 = const 1f64 as i16 (FloatToInt);
-          _77 = opaque::<i16>(move _78) -> [return: bb26, unwind continue];
++         _79 = const 1f64;
++         _78 = const 1_i16;
+          StorageDead(_79);
+-         _77 = opaque::<i16>(move _78) -> [return: bb26, unwind continue];
++         _77 = opaque::<i16>(const 1_i16) -> [return: bb26, unwind continue];
       }
   
       bb26: {
@@ -444,12 +497,14 @@
           StorageDead(_77);
           StorageLive(_80);
           StorageLive(_81);
--         StorageLive(_82);
+          StorageLive(_82);
 -         _82 = _3;
 -         _81 = move _82 as i32 (FloatToInt);
--         StorageDead(_82);
-+         _81 = const 1f64 as i32 (FloatToInt);
-          _80 = opaque::<i32>(move _81) -> [return: bb27, unwind continue];
++         _82 = const 1f64;
++         _81 = const 1_i32;
+          StorageDead(_82);
+-         _80 = opaque::<i32>(move _81) -> [return: bb27, unwind continue];
++         _80 = opaque::<i32>(const 1_i32) -> [return: bb27, unwind continue];
       }
   
       bb27: {
@@ -457,12 +512,14 @@
           StorageDead(_80);
           StorageLive(_83);
           StorageLive(_84);
--         StorageLive(_85);
+          StorageLive(_85);
 -         _85 = _3;
 -         _84 = move _85 as i64 (FloatToInt);
--         StorageDead(_85);
-+         _84 = const 1f64 as i64 (FloatToInt);
-          _83 = opaque::<i64>(move _84) -> [return: bb28, unwind continue];
++         _85 = const 1f64;
++         _84 = const 1_i64;
+          StorageDead(_85);
+-         _83 = opaque::<i64>(move _84) -> [return: bb28, unwind continue];
++         _83 = opaque::<i64>(const 1_i64) -> [return: bb28, unwind continue];
       }
   
       bb28: {
@@ -470,31 +527,37 @@
           StorageDead(_83);
           StorageLive(_86);
           StorageLive(_87);
--         StorageLive(_88);
+          StorageLive(_88);
 -         _88 = _3;
 -         _87 = move _88 as f32 (FloatToFloat);
--         StorageDead(_88);
-+         _87 = const 1f64 as f32 (FloatToFloat);
-          _86 = opaque::<f32>(move _87) -> [return: bb29, unwind continue];
++         _88 = const 1f64;
++         _87 = const 1f32;
+          StorageDead(_88);
+-         _86 = opaque::<f32>(move _87) -> [return: bb29, unwind continue];
++         _86 = opaque::<f32>(const 1f32) -> [return: bb29, unwind continue];
       }
   
       bb29: {
           StorageDead(_87);
           StorageDead(_86);
           StorageLive(_89);
--         StorageLive(_90);
+          StorageLive(_90);
 -         _90 = _3;
 -         _89 = opaque::<f64>(move _90) -> [return: bb30, unwind continue];
++         _90 = const 1f64;
 +         _89 = opaque::<f64>(const 1f64) -> [return: bb30, unwind continue];
       }
   
       bb30: {
--         StorageDead(_90);
+          StorageDead(_90);
           StorageDead(_89);
           _0 = const ();
 -         StorageDead(_3);
 -         StorageDead(_2);
 -         StorageDead(_1);
++         nop;
++         nop;
++         nop;
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.comparison.GVN.panic-abort.diff b/tests/mir-opt/gvn.comparison.GVN.panic-abort.diff
new file mode 100644
index 00000000000..ee3b9da2122
--- /dev/null
+++ b/tests/mir-opt/gvn.comparison.GVN.panic-abort.diff
@@ -0,0 +1,94 @@
+- // MIR for `comparison` before GVN
++ // MIR for `comparison` after GVN
+  
+  fn comparison(_1: u64, _2: u64) -> () {
+      debug x => _1;
+      debug y => _2;
+      let mut _0: ();
+      let _3: ();
+      let mut _4: bool;
+      let mut _5: u64;
+      let mut _6: u64;
+      let _7: ();
+      let mut _8: bool;
+      let mut _9: u64;
+      let mut _10: u64;
+      let _11: ();
+      let mut _12: bool;
+      let mut _13: u64;
+      let mut _14: u64;
+      let _15: ();
+      let mut _16: bool;
+      let mut _17: u64;
+      let mut _18: u64;
+  
+      bb0: {
+          StorageLive(_3);
+          StorageLive(_4);
+          StorageLive(_5);
+          _5 = _1;
+          StorageLive(_6);
+          _6 = _1;
+-         _4 = Eq(move _5, move _6);
++         _4 = Eq(_1, _1);
+          StorageDead(_6);
+          StorageDead(_5);
+          _3 = opaque::<bool>(move _4) -> [return: bb1, unwind unreachable];
+      }
+  
+      bb1: {
+          StorageDead(_4);
+          StorageDead(_3);
+          StorageLive(_7);
+          StorageLive(_8);
+          StorageLive(_9);
+          _9 = _1;
+          StorageLive(_10);
+          _10 = _1;
+-         _8 = Ne(move _9, move _10);
++         _8 = Ne(_1, _1);
+          StorageDead(_10);
+          StorageDead(_9);
+          _7 = opaque::<bool>(move _8) -> [return: bb2, unwind unreachable];
+      }
+  
+      bb2: {
+          StorageDead(_8);
+          StorageDead(_7);
+          StorageLive(_11);
+          StorageLive(_12);
+          StorageLive(_13);
+          _13 = _1;
+          StorageLive(_14);
+          _14 = _2;
+-         _12 = Eq(move _13, move _14);
++         _12 = Eq(_1, _2);
+          StorageDead(_14);
+          StorageDead(_13);
+          _11 = opaque::<bool>(move _12) -> [return: bb3, unwind unreachable];
+      }
+  
+      bb3: {
+          StorageDead(_12);
+          StorageDead(_11);
+          StorageLive(_15);
+          StorageLive(_16);
+          StorageLive(_17);
+          _17 = _1;
+          StorageLive(_18);
+          _18 = _2;
+-         _16 = Ne(move _17, move _18);
++         _16 = Ne(_1, _2);
+          StorageDead(_18);
+          StorageDead(_17);
+          _15 = opaque::<bool>(move _16) -> [return: bb4, unwind unreachable];
+      }
+  
+      bb4: {
+          StorageDead(_16);
+          StorageDead(_15);
+          _0 = const ();
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/gvn.comparison.GVN.panic-unwind.diff b/tests/mir-opt/gvn.comparison.GVN.panic-unwind.diff
new file mode 100644
index 00000000000..a1408fe3434
--- /dev/null
+++ b/tests/mir-opt/gvn.comparison.GVN.panic-unwind.diff
@@ -0,0 +1,94 @@
+- // MIR for `comparison` before GVN
++ // MIR for `comparison` after GVN
+  
+  fn comparison(_1: u64, _2: u64) -> () {
+      debug x => _1;
+      debug y => _2;
+      let mut _0: ();
+      let _3: ();
+      let mut _4: bool;
+      let mut _5: u64;
+      let mut _6: u64;
+      let _7: ();
+      let mut _8: bool;
+      let mut _9: u64;
+      let mut _10: u64;
+      let _11: ();
+      let mut _12: bool;
+      let mut _13: u64;
+      let mut _14: u64;
+      let _15: ();
+      let mut _16: bool;
+      let mut _17: u64;
+      let mut _18: u64;
+  
+      bb0: {
+          StorageLive(_3);
+          StorageLive(_4);
+          StorageLive(_5);
+          _5 = _1;
+          StorageLive(_6);
+          _6 = _1;
+-         _4 = Eq(move _5, move _6);
++         _4 = Eq(_1, _1);
+          StorageDead(_6);
+          StorageDead(_5);
+          _3 = opaque::<bool>(move _4) -> [return: bb1, unwind continue];
+      }
+  
+      bb1: {
+          StorageDead(_4);
+          StorageDead(_3);
+          StorageLive(_7);
+          StorageLive(_8);
+          StorageLive(_9);
+          _9 = _1;
+          StorageLive(_10);
+          _10 = _1;
+-         _8 = Ne(move _9, move _10);
++         _8 = Ne(_1, _1);
+          StorageDead(_10);
+          StorageDead(_9);
+          _7 = opaque::<bool>(move _8) -> [return: bb2, unwind continue];
+      }
+  
+      bb2: {
+          StorageDead(_8);
+          StorageDead(_7);
+          StorageLive(_11);
+          StorageLive(_12);
+          StorageLive(_13);
+          _13 = _1;
+          StorageLive(_14);
+          _14 = _2;
+-         _12 = Eq(move _13, move _14);
++         _12 = Eq(_1, _2);
+          StorageDead(_14);
+          StorageDead(_13);
+          _11 = opaque::<bool>(move _12) -> [return: bb3, unwind continue];
+      }
+  
+      bb3: {
+          StorageDead(_12);
+          StorageDead(_11);
+          StorageLive(_15);
+          StorageLive(_16);
+          StorageLive(_17);
+          _17 = _1;
+          StorageLive(_18);
+          _18 = _2;
+-         _16 = Ne(move _17, move _18);
++         _16 = Ne(_1, _2);
+          StorageDead(_18);
+          StorageDead(_17);
+          _15 = opaque::<bool>(move _16) -> [return: bb4, unwind continue];
+      }
+  
+      bb4: {
+          StorageDead(_16);
+          StorageDead(_15);
+          _0 = const ();
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff
index ee320cf6787..a587b1e6b1d 100644
--- a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff
@@ -72,7 +72,8 @@
       bb2: {
           StorageDead(_7);
           StorageDead(_6);
-          StorageLive(_8);
+-         StorageLive(_8);
++         nop;
           _8 = &raw const (*_1);
           StorageLive(_9);
           StorageLive(_10);
@@ -92,7 +93,8 @@
       bb4: {
           StorageDead(_12);
           StorageDead(_11);
-          StorageLive(_13);
+-         StorageLive(_13);
++         nop;
           _13 = &raw mut (*_1);
           StorageLive(_14);
           StorageLive(_15);
@@ -112,10 +114,12 @@
       bb6: {
           StorageDead(_17);
           StorageDead(_16);
-          StorageLive(_18);
+-         StorageLive(_18);
++         nop;
           _18 = &(*_1);
           StorageLive(_19);
 -         StorageLive(_20);
++         nop;
           _20 = (*_18);
 -         _19 = opaque::<u32>(move _20) -> [return: bb7, unwind unreachable];
 +         _19 = opaque::<u32>(_20) -> [return: bb7, unwind unreachable];
@@ -123,16 +127,18 @@
   
       bb7: {
 -         StorageDead(_20);
++         nop;
           StorageDead(_19);
           StorageLive(_21);
--         StorageLive(_22);
+          StorageLive(_22);
 -         _22 = (*_18);
 -         _21 = opaque::<u32>(move _22) -> [return: bb8, unwind unreachable];
++         _22 = _20;
 +         _21 = opaque::<u32>(_20) -> [return: bb8, unwind unreachable];
       }
   
       bb8: {
--         StorageDead(_22);
+          StorageDead(_22);
           StorageDead(_21);
           StorageLive(_23);
           StorageLive(_24);
@@ -163,6 +169,7 @@
           StorageDead(_27);
           StorageLive(_29);
 -         StorageLive(_30);
++         nop;
           _30 = ((*_3).0: u32);
 -         _29 = opaque::<u32>(move _30) -> [return: bb12, unwind unreachable];
 +         _29 = opaque::<u32>(_30) -> [return: bb12, unwind unreachable];
@@ -170,21 +177,26 @@
   
       bb12: {
 -         StorageDead(_30);
++         nop;
           StorageDead(_29);
           StorageLive(_31);
--         StorageLive(_32);
+          StorageLive(_32);
 -         _32 = ((*_3).0: u32);
 -         _31 = opaque::<u32>(move _32) -> [return: bb13, unwind unreachable];
++         _32 = _30;
 +         _31 = opaque::<u32>(_30) -> [return: bb13, unwind unreachable];
       }
   
       bb13: {
--         StorageDead(_32);
+          StorageDead(_32);
           StorageDead(_31);
           _0 = const ();
-          StorageDead(_18);
-          StorageDead(_13);
-          StorageDead(_8);
+-         StorageDead(_18);
+-         StorageDead(_13);
+-         StorageDead(_8);
++         nop;
++         nop;
++         nop;
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff
index f627b4d5988..6fdda5e9988 100644
--- a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff
@@ -72,7 +72,8 @@
       bb2: {
           StorageDead(_7);
           StorageDead(_6);
-          StorageLive(_8);
+-         StorageLive(_8);
++         nop;
           _8 = &raw const (*_1);
           StorageLive(_9);
           StorageLive(_10);
@@ -92,7 +93,8 @@
       bb4: {
           StorageDead(_12);
           StorageDead(_11);
-          StorageLive(_13);
+-         StorageLive(_13);
++         nop;
           _13 = &raw mut (*_1);
           StorageLive(_14);
           StorageLive(_15);
@@ -112,10 +114,12 @@
       bb6: {
           StorageDead(_17);
           StorageDead(_16);
-          StorageLive(_18);
+-         StorageLive(_18);
++         nop;
           _18 = &(*_1);
           StorageLive(_19);
 -         StorageLive(_20);
++         nop;
           _20 = (*_18);
 -         _19 = opaque::<u32>(move _20) -> [return: bb7, unwind continue];
 +         _19 = opaque::<u32>(_20) -> [return: bb7, unwind continue];
@@ -123,16 +127,18 @@
   
       bb7: {
 -         StorageDead(_20);
++         nop;
           StorageDead(_19);
           StorageLive(_21);
--         StorageLive(_22);
+          StorageLive(_22);
 -         _22 = (*_18);
 -         _21 = opaque::<u32>(move _22) -> [return: bb8, unwind continue];
++         _22 = _20;
 +         _21 = opaque::<u32>(_20) -> [return: bb8, unwind continue];
       }
   
       bb8: {
--         StorageDead(_22);
+          StorageDead(_22);
           StorageDead(_21);
           StorageLive(_23);
           StorageLive(_24);
@@ -163,6 +169,7 @@
           StorageDead(_27);
           StorageLive(_29);
 -         StorageLive(_30);
++         nop;
           _30 = ((*_3).0: u32);
 -         _29 = opaque::<u32>(move _30) -> [return: bb12, unwind continue];
 +         _29 = opaque::<u32>(_30) -> [return: bb12, unwind continue];
@@ -170,21 +177,26 @@
   
       bb12: {
 -         StorageDead(_30);
++         nop;
           StorageDead(_29);
           StorageLive(_31);
--         StorageLive(_32);
+          StorageLive(_32);
 -         _32 = ((*_3).0: u32);
 -         _31 = opaque::<u32>(move _32) -> [return: bb13, unwind continue];
++         _32 = _30;
 +         _31 = opaque::<u32>(_30) -> [return: bb13, unwind continue];
       }
   
       bb13: {
--         StorageDead(_32);
+          StorageDead(_32);
           StorageDead(_31);
           _0 = const ();
-          StorageDead(_18);
-          StorageDead(_13);
-          StorageDead(_8);
+-         StorageDead(_18);
+-         StorageDead(_13);
+-         StorageDead(_8);
++         nop;
++         nop;
++         nop;
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.duplicate_slice.GVN.panic-abort.diff b/tests/mir-opt/gvn.duplicate_slice.GVN.panic-abort.diff
new file mode 100644
index 00000000000..7ae1fae68e8
--- /dev/null
+++ b/tests/mir-opt/gvn.duplicate_slice.GVN.panic-abort.diff
@@ -0,0 +1,38 @@
+- // MIR for `duplicate_slice` before GVN
++ // MIR for `duplicate_slice` after GVN
+  
+  fn duplicate_slice() -> (bool, bool) {
+      let mut _0: (bool, bool);
+      let mut _1: u128;
+      let mut _2: u128;
+      let mut _3: u128;
+      let mut _4: u128;
+      let mut _5: &str;
+      let mut _6: &str;
+      let mut _7: (&str,);
+      let mut _8: &str;
+      let mut _9: bool;
+      let mut _10: bool;
+  
+      bb0: {
+          _7 = (const "a",);
+          _1 = (_7.0: &str) as u128 (Transmute);
+          _5 = identity::<&str>((_7.0: &str)) -> [return: bb1, unwind unreachable];
+      }
+  
+      bb1: {
+          _3 = _5 as u128 (Transmute);
+          _8 = const "a";
+          _2 = _8 as u128 (Transmute);
+          _6 = identity::<&str>(_8) -> [return: bb2, unwind unreachable];
+      }
+  
+      bb2: {
+          _4 = _6 as u128 (Transmute);
+          _9 = Eq(_1, _2);
+          _10 = Eq(_3, _4);
+          _0 = (_9, _10);
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/gvn.duplicate_slice.GVN.panic-unwind.diff b/tests/mir-opt/gvn.duplicate_slice.GVN.panic-unwind.diff
new file mode 100644
index 00000000000..8c96edaa280
--- /dev/null
+++ b/tests/mir-opt/gvn.duplicate_slice.GVN.panic-unwind.diff
@@ -0,0 +1,38 @@
+- // MIR for `duplicate_slice` before GVN
++ // MIR for `duplicate_slice` after GVN
+  
+  fn duplicate_slice() -> (bool, bool) {
+      let mut _0: (bool, bool);
+      let mut _1: u128;
+      let mut _2: u128;
+      let mut _3: u128;
+      let mut _4: u128;
+      let mut _5: &str;
+      let mut _6: &str;
+      let mut _7: (&str,);
+      let mut _8: &str;
+      let mut _9: bool;
+      let mut _10: bool;
+  
+      bb0: {
+          _7 = (const "a",);
+          _1 = (_7.0: &str) as u128 (Transmute);
+          _5 = identity::<&str>((_7.0: &str)) -> [return: bb1, unwind continue];
+      }
+  
+      bb1: {
+          _3 = _5 as u128 (Transmute);
+          _8 = const "a";
+          _2 = _8 as u128 (Transmute);
+          _6 = identity::<&str>(_8) -> [return: bb2, unwind continue];
+      }
+  
+      bb2: {
+          _4 = _6 as u128 (Transmute);
+          _9 = Eq(_1, _2);
+          _10 = Eq(_3, _4);
+          _0 = (_9, _10);
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff
new file mode 100644
index 00000000000..d8248d22d38
--- /dev/null
+++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff
@@ -0,0 +1,118 @@
+- // MIR for `fn_pointers` before GVN
++ // MIR for `fn_pointers` after GVN
+  
+  fn fn_pointers() -> () {
+      let mut _0: ();
+      let _1: fn(u8) -> u8;
+      let _2: ();
+      let mut _3: fn(u8) -> u8;
+      let _5: ();
+      let mut _6: fn(u8) -> u8;
+      let mut _9: {closure@$DIR/gvn.rs:591:19: 591:21};
+      let _10: ();
+      let mut _11: fn();
+      let mut _13: {closure@$DIR/gvn.rs:591:19: 591:21};
+      let _14: ();
+      let mut _15: fn();
+      scope 1 {
+          debug f => _1;
+          let _4: fn(u8) -> u8;
+          scope 2 {
+              debug g => _4;
+              let _7: {closure@$DIR/gvn.rs:591:19: 591:21};
+              scope 3 {
+                  debug closure => _7;
+                  let _8: fn();
+                  scope 4 {
+                      debug cf => _8;
+                      let _12: fn();
+                      scope 5 {
+                          debug cg => _12;
+                      }
+                  }
+              }
+          }
+      }
+  
+      bb0: {
+-         StorageLive(_1);
++         nop;
+          _1 = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer));
+          StorageLive(_2);
+          StorageLive(_3);
+          _3 = _1;
+-         _2 = opaque::<fn(u8) -> u8>(move _3) -> [return: bb1, unwind unreachable];
++         _2 = opaque::<fn(u8) -> u8>(_1) -> [return: bb1, unwind unreachable];
+      }
+  
+      bb1: {
+          StorageDead(_3);
+          StorageDead(_2);
+-         StorageLive(_4);
++         nop;
+          _4 = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer));
+          StorageLive(_5);
+          StorageLive(_6);
+          _6 = _4;
+-         _5 = opaque::<fn(u8) -> u8>(move _6) -> [return: bb2, unwind unreachable];
++         _5 = opaque::<fn(u8) -> u8>(_4) -> [return: bb2, unwind unreachable];
+      }
+  
+      bb2: {
+          StorageDead(_6);
+          StorageDead(_5);
+-         StorageLive(_7);
+-         _7 = {closure@$DIR/gvn.rs:591:19: 591:21};
+-         StorageLive(_8);
++         nop;
++         _7 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21};
++         nop;
+          StorageLive(_9);
+-         _9 = _7;
+-         _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Normal)));
++         _9 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21};
++         _8 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21} as fn() (PointerCoercion(ClosureFnPointer(Normal)));
+          StorageDead(_9);
+          StorageLive(_10);
+          StorageLive(_11);
+          _11 = _8;
+-         _10 = opaque::<fn()>(move _11) -> [return: bb3, unwind unreachable];
++         _10 = opaque::<fn()>(_8) -> [return: bb3, unwind unreachable];
+      }
+  
+      bb3: {
+          StorageDead(_11);
+          StorageDead(_10);
+-         StorageLive(_12);
++         nop;
+          StorageLive(_13);
+-         _13 = _7;
+-         _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Normal)));
++         _13 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21};
++         _12 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21} as fn() (PointerCoercion(ClosureFnPointer(Normal)));
+          StorageDead(_13);
+          StorageLive(_14);
+          StorageLive(_15);
+          _15 = _12;
+-         _14 = opaque::<fn()>(move _15) -> [return: bb4, unwind unreachable];
++         _14 = opaque::<fn()>(_12) -> [return: bb4, unwind unreachable];
+      }
+  
+      bb4: {
+          StorageDead(_15);
+          StorageDead(_14);
+          _0 = const ();
+-         StorageDead(_12);
+-         StorageDead(_8);
+-         StorageDead(_7);
+-         StorageDead(_4);
+-         StorageDead(_1);
++         nop;
++         nop;
++         nop;
++         nop;
++         nop;
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff
new file mode 100644
index 00000000000..e38a3d85209
--- /dev/null
+++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff
@@ -0,0 +1,118 @@
+- // MIR for `fn_pointers` before GVN
++ // MIR for `fn_pointers` after GVN
+  
+  fn fn_pointers() -> () {
+      let mut _0: ();
+      let _1: fn(u8) -> u8;
+      let _2: ();
+      let mut _3: fn(u8) -> u8;
+      let _5: ();
+      let mut _6: fn(u8) -> u8;
+      let mut _9: {closure@$DIR/gvn.rs:591:19: 591:21};
+      let _10: ();
+      let mut _11: fn();
+      let mut _13: {closure@$DIR/gvn.rs:591:19: 591:21};
+      let _14: ();
+      let mut _15: fn();
+      scope 1 {
+          debug f => _1;
+          let _4: fn(u8) -> u8;
+          scope 2 {
+              debug g => _4;
+              let _7: {closure@$DIR/gvn.rs:591:19: 591:21};
+              scope 3 {
+                  debug closure => _7;
+                  let _8: fn();
+                  scope 4 {
+                      debug cf => _8;
+                      let _12: fn();
+                      scope 5 {
+                          debug cg => _12;
+                      }
+                  }
+              }
+          }
+      }
+  
+      bb0: {
+-         StorageLive(_1);
++         nop;
+          _1 = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer));
+          StorageLive(_2);
+          StorageLive(_3);
+          _3 = _1;
+-         _2 = opaque::<fn(u8) -> u8>(move _3) -> [return: bb1, unwind continue];
++         _2 = opaque::<fn(u8) -> u8>(_1) -> [return: bb1, unwind continue];
+      }
+  
+      bb1: {
+          StorageDead(_3);
+          StorageDead(_2);
+-         StorageLive(_4);
++         nop;
+          _4 = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer));
+          StorageLive(_5);
+          StorageLive(_6);
+          _6 = _4;
+-         _5 = opaque::<fn(u8) -> u8>(move _6) -> [return: bb2, unwind continue];
++         _5 = opaque::<fn(u8) -> u8>(_4) -> [return: bb2, unwind continue];
+      }
+  
+      bb2: {
+          StorageDead(_6);
+          StorageDead(_5);
+-         StorageLive(_7);
+-         _7 = {closure@$DIR/gvn.rs:591:19: 591:21};
+-         StorageLive(_8);
++         nop;
++         _7 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21};
++         nop;
+          StorageLive(_9);
+-         _9 = _7;
+-         _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Normal)));
++         _9 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21};
++         _8 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21} as fn() (PointerCoercion(ClosureFnPointer(Normal)));
+          StorageDead(_9);
+          StorageLive(_10);
+          StorageLive(_11);
+          _11 = _8;
+-         _10 = opaque::<fn()>(move _11) -> [return: bb3, unwind continue];
++         _10 = opaque::<fn()>(_8) -> [return: bb3, unwind continue];
+      }
+  
+      bb3: {
+          StorageDead(_11);
+          StorageDead(_10);
+-         StorageLive(_12);
++         nop;
+          StorageLive(_13);
+-         _13 = _7;
+-         _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Normal)));
++         _13 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21};
++         _12 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21} as fn() (PointerCoercion(ClosureFnPointer(Normal)));
+          StorageDead(_13);
+          StorageLive(_14);
+          StorageLive(_15);
+          _15 = _12;
+-         _14 = opaque::<fn()>(move _15) -> [return: bb4, unwind continue];
++         _14 = opaque::<fn()>(_12) -> [return: bb4, unwind continue];
+      }
+  
+      bb4: {
+          StorageDead(_15);
+          StorageDead(_14);
+          _0 = const ();
+-         StorageDead(_12);
+-         StorageDead(_8);
+-         StorageDead(_7);
+-         StorageDead(_4);
+-         StorageDead(_1);
++         nop;
++         nop;
++         nop;
++         nop;
++         nop;
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/gvn.indirect_static.GVN.panic-abort.diff b/tests/mir-opt/gvn.indirect_static.GVN.panic-abort.diff
new file mode 100644
index 00000000000..f853942bbb6
--- /dev/null
+++ b/tests/mir-opt/gvn.indirect_static.GVN.panic-abort.diff
@@ -0,0 +1,19 @@
+- // MIR for `indirect_static` before GVN
++ // MIR for `indirect_static` after GVN
+  
+  fn indirect_static() -> () {
+      let mut _0: ();
+      let mut _1: &std::option::Option<u8>;
+      let mut _2: u8;
+  
+      bb0: {
+          _1 = const {ALLOC0: &Option<u8>};
+          _2 = (((*_1) as variant#1).0: u8);
+          return;
+      }
+  }
+  
+  ALLOC0 (static: A, size: 2, align: 1) {
+      00 __                                           │ .░
+  }
+  
diff --git a/tests/mir-opt/gvn.indirect_static.GVN.panic-unwind.diff b/tests/mir-opt/gvn.indirect_static.GVN.panic-unwind.diff
new file mode 100644
index 00000000000..f853942bbb6
--- /dev/null
+++ b/tests/mir-opt/gvn.indirect_static.GVN.panic-unwind.diff
@@ -0,0 +1,19 @@
+- // MIR for `indirect_static` before GVN
++ // MIR for `indirect_static` after GVN
+  
+  fn indirect_static() -> () {
+      let mut _0: ();
+      let mut _1: &std::option::Option<u8>;
+      let mut _2: u8;
+  
+      bb0: {
+          _1 = const {ALLOC0: &Option<u8>};
+          _2 = (((*_1) as variant#1).0: u8);
+          return;
+      }
+  }
+  
+  ALLOC0 (static: A, size: 2, align: 1) {
+      00 __                                           │ .░
+  }
+  
diff --git a/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff b/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff
index 0a66900283b..29ca1ba5902 100644
--- a/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff
@@ -39,9 +39,9 @@
       let mut _34: u8;
   
       bb0: {
--         StorageLive(_4);
--         StorageLive(_5);
--         _5 = _1;
+          StorageLive(_4);
+          StorageLive(_5);
+          _5 = _1;
 -         switchInt(move _5) -> [0: bb4, otherwise: bb1];
 +         switchInt(_1) -> [0: bb4, otherwise: bb1];
       }
@@ -49,121 +49,130 @@
       bb1: {
           StorageLive(_6);
 -         StorageLive(_7);
--         StorageLive(_8);
--         _8 = _2;
--         StorageLive(_9);
--         _9 = _3;
++         nop;
+          StorageLive(_8);
+          _8 = _2;
+          StorageLive(_9);
+          _9 = _3;
 -         _7 = Add(move _8, move _9);
--         StorageDead(_9);
--         StorageDead(_8);
--         _6 = opaque::<u8>(move _7) -> [return: bb2, unwind unreachable];
 +         _7 = Add(_2, _3);
+          StorageDead(_9);
+          StorageDead(_8);
+-         _6 = opaque::<u8>(move _7) -> [return: bb2, unwind unreachable];
 +         _6 = opaque::<u8>(_7) -> [return: bb2, unwind unreachable];
       }
   
       bb2: {
 -         StorageDead(_7);
++         nop;
           StorageDead(_6);
           StorageLive(_10);
--         StorageLive(_11);
--         StorageLive(_12);
--         _12 = _2;
--         StorageLive(_13);
--         _13 = _3;
+          StorageLive(_11);
+          StorageLive(_12);
+          _12 = _2;
+          StorageLive(_13);
+          _13 = _3;
 -         _11 = Add(move _12, move _13);
--         StorageDead(_13);
--         StorageDead(_12);
++         _11 = _7;
+          StorageDead(_13);
+          StorageDead(_12);
 -         _10 = opaque::<u8>(move _11) -> [return: bb3, unwind unreachable];
 +         _10 = opaque::<u8>(_7) -> [return: bb3, unwind unreachable];
       }
   
       bb3: {
--         StorageDead(_11);
+          StorageDead(_11);
           StorageDead(_10);
--         _4 = const ();
+          _4 = const ();
           goto -> bb7;
       }
   
       bb4: {
           StorageLive(_14);
 -         StorageLive(_15);
--         StorageLive(_16);
--         _16 = _2;
--         StorageLive(_17);
--         _17 = _3;
++         nop;
+          StorageLive(_16);
+          _16 = _2;
+          StorageLive(_17);
+          _17 = _3;
 -         _15 = Add(move _16, move _17);
--         StorageDead(_17);
--         StorageDead(_16);
--         _14 = opaque::<u8>(move _15) -> [return: bb5, unwind unreachable];
 +         _15 = Add(_2, _3);
+          StorageDead(_17);
+          StorageDead(_16);
+-         _14 = opaque::<u8>(move _15) -> [return: bb5, unwind unreachable];
 +         _14 = opaque::<u8>(_15) -> [return: bb5, unwind unreachable];
       }
   
       bb5: {
 -         StorageDead(_15);
++         nop;
           StorageDead(_14);
           StorageLive(_18);
--         StorageLive(_19);
--         StorageLive(_20);
--         _20 = _2;
--         StorageLive(_21);
--         _21 = _3;
+          StorageLive(_19);
+          StorageLive(_20);
+          _20 = _2;
+          StorageLive(_21);
+          _21 = _3;
 -         _19 = Add(move _20, move _21);
--         StorageDead(_21);
--         StorageDead(_20);
++         _19 = _15;
+          StorageDead(_21);
+          StorageDead(_20);
 -         _18 = opaque::<u8>(move _19) -> [return: bb6, unwind unreachable];
 +         _18 = opaque::<u8>(_15) -> [return: bb6, unwind unreachable];
       }
   
       bb6: {
--         StorageDead(_19);
+          StorageDead(_19);
           StorageDead(_18);
--         _4 = const ();
+          _4 = const ();
           goto -> bb7;
       }
   
       bb7: {
--         StorageDead(_5);
--         StorageDead(_4);
+          StorageDead(_5);
+          StorageDead(_4);
           StorageLive(_22);
 -         StorageLive(_23);
--         StorageLive(_24);
--         _24 = _2;
--         StorageLive(_25);
--         _25 = _3;
++         nop;
+          StorageLive(_24);
+          _24 = _2;
+          StorageLive(_25);
+          _25 = _3;
 -         _23 = Add(move _24, move _25);
--         StorageDead(_25);
--         StorageDead(_24);
--         _22 = opaque::<u8>(move _23) -> [return: bb8, unwind unreachable];
 +         _23 = Add(_2, _3);
+          StorageDead(_25);
+          StorageDead(_24);
+-         _22 = opaque::<u8>(move _23) -> [return: bb8, unwind unreachable];
 +         _22 = opaque::<u8>(_23) -> [return: bb8, unwind unreachable];
       }
   
       bb8: {
 -         StorageDead(_23);
++         nop;
           StorageDead(_22);
--         StorageLive(_26);
--         _26 = _1;
+          StorageLive(_26);
+          _26 = _1;
 -         switchInt(move _26) -> [0: bb11, otherwise: bb9];
 +         switchInt(_1) -> [0: bb11, otherwise: bb9];
       }
   
       bb9: {
           StorageLive(_27);
--         StorageLive(_28);
--         StorageLive(_29);
--         _29 = _2;
--         StorageLive(_30);
--         _30 = _3;
+          StorageLive(_28);
+          StorageLive(_29);
+          _29 = _2;
+          StorageLive(_30);
+          _30 = _3;
 -         _28 = Add(move _29, move _30);
--         StorageDead(_30);
--         StorageDead(_29);
++         _28 = _23;
+          StorageDead(_30);
+          StorageDead(_29);
 -         _27 = opaque::<u8>(move _28) -> [return: bb10, unwind unreachable];
 +         _27 = opaque::<u8>(_23) -> [return: bb10, unwind unreachable];
       }
   
       bb10: {
--         StorageDead(_28);
+          StorageDead(_28);
           StorageDead(_27);
           _0 = const ();
           goto -> bb13;
@@ -171,27 +180,28 @@
   
       bb11: {
           StorageLive(_31);
--         StorageLive(_32);
--         StorageLive(_33);
--         _33 = _2;
--         StorageLive(_34);
--         _34 = _3;
+          StorageLive(_32);
+          StorageLive(_33);
+          _33 = _2;
+          StorageLive(_34);
+          _34 = _3;
 -         _32 = Add(move _33, move _34);
--         StorageDead(_34);
--         StorageDead(_33);
++         _32 = _23;
+          StorageDead(_34);
+          StorageDead(_33);
 -         _31 = opaque::<u8>(move _32) -> [return: bb12, unwind unreachable];
 +         _31 = opaque::<u8>(_23) -> [return: bb12, unwind unreachable];
       }
   
       bb12: {
--         StorageDead(_32);
+          StorageDead(_32);
           StorageDead(_31);
           _0 = const ();
           goto -> bb13;
       }
   
       bb13: {
--         StorageDead(_26);
+          StorageDead(_26);
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff b/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff
index 0199f2720a9..5394dc8be8a 100644
--- a/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff
@@ -39,9 +39,9 @@
       let mut _34: u8;
   
       bb0: {
--         StorageLive(_4);
--         StorageLive(_5);
--         _5 = _1;
+          StorageLive(_4);
+          StorageLive(_5);
+          _5 = _1;
 -         switchInt(move _5) -> [0: bb4, otherwise: bb1];
 +         switchInt(_1) -> [0: bb4, otherwise: bb1];
       }
@@ -49,121 +49,130 @@
       bb1: {
           StorageLive(_6);
 -         StorageLive(_7);
--         StorageLive(_8);
--         _8 = _2;
--         StorageLive(_9);
--         _9 = _3;
++         nop;
+          StorageLive(_8);
+          _8 = _2;
+          StorageLive(_9);
+          _9 = _3;
 -         _7 = Add(move _8, move _9);
--         StorageDead(_9);
--         StorageDead(_8);
--         _6 = opaque::<u8>(move _7) -> [return: bb2, unwind continue];
 +         _7 = Add(_2, _3);
+          StorageDead(_9);
+          StorageDead(_8);
+-         _6 = opaque::<u8>(move _7) -> [return: bb2, unwind continue];
 +         _6 = opaque::<u8>(_7) -> [return: bb2, unwind continue];
       }
   
       bb2: {
 -         StorageDead(_7);
++         nop;
           StorageDead(_6);
           StorageLive(_10);
--         StorageLive(_11);
--         StorageLive(_12);
--         _12 = _2;
--         StorageLive(_13);
--         _13 = _3;
+          StorageLive(_11);
+          StorageLive(_12);
+          _12 = _2;
+          StorageLive(_13);
+          _13 = _3;
 -         _11 = Add(move _12, move _13);
--         StorageDead(_13);
--         StorageDead(_12);
++         _11 = _7;
+          StorageDead(_13);
+          StorageDead(_12);
 -         _10 = opaque::<u8>(move _11) -> [return: bb3, unwind continue];
 +         _10 = opaque::<u8>(_7) -> [return: bb3, unwind continue];
       }
   
       bb3: {
--         StorageDead(_11);
+          StorageDead(_11);
           StorageDead(_10);
--         _4 = const ();
+          _4 = const ();
           goto -> bb7;
       }
   
       bb4: {
           StorageLive(_14);
 -         StorageLive(_15);
--         StorageLive(_16);
--         _16 = _2;
--         StorageLive(_17);
--         _17 = _3;
++         nop;
+          StorageLive(_16);
+          _16 = _2;
+          StorageLive(_17);
+          _17 = _3;
 -         _15 = Add(move _16, move _17);
--         StorageDead(_17);
--         StorageDead(_16);
--         _14 = opaque::<u8>(move _15) -> [return: bb5, unwind continue];
 +         _15 = Add(_2, _3);
+          StorageDead(_17);
+          StorageDead(_16);
+-         _14 = opaque::<u8>(move _15) -> [return: bb5, unwind continue];
 +         _14 = opaque::<u8>(_15) -> [return: bb5, unwind continue];
       }
   
       bb5: {
 -         StorageDead(_15);
++         nop;
           StorageDead(_14);
           StorageLive(_18);
--         StorageLive(_19);
--         StorageLive(_20);
--         _20 = _2;
--         StorageLive(_21);
--         _21 = _3;
+          StorageLive(_19);
+          StorageLive(_20);
+          _20 = _2;
+          StorageLive(_21);
+          _21 = _3;
 -         _19 = Add(move _20, move _21);
--         StorageDead(_21);
--         StorageDead(_20);
++         _19 = _15;
+          StorageDead(_21);
+          StorageDead(_20);
 -         _18 = opaque::<u8>(move _19) -> [return: bb6, unwind continue];
 +         _18 = opaque::<u8>(_15) -> [return: bb6, unwind continue];
       }
   
       bb6: {
--         StorageDead(_19);
+          StorageDead(_19);
           StorageDead(_18);
--         _4 = const ();
+          _4 = const ();
           goto -> bb7;
       }
   
       bb7: {
--         StorageDead(_5);
--         StorageDead(_4);
+          StorageDead(_5);
+          StorageDead(_4);
           StorageLive(_22);
 -         StorageLive(_23);
--         StorageLive(_24);
--         _24 = _2;
--         StorageLive(_25);
--         _25 = _3;
++         nop;
+          StorageLive(_24);
+          _24 = _2;
+          StorageLive(_25);
+          _25 = _3;
 -         _23 = Add(move _24, move _25);
--         StorageDead(_25);
--         StorageDead(_24);
--         _22 = opaque::<u8>(move _23) -> [return: bb8, unwind continue];
 +         _23 = Add(_2, _3);
+          StorageDead(_25);
+          StorageDead(_24);
+-         _22 = opaque::<u8>(move _23) -> [return: bb8, unwind continue];
 +         _22 = opaque::<u8>(_23) -> [return: bb8, unwind continue];
       }
   
       bb8: {
 -         StorageDead(_23);
++         nop;
           StorageDead(_22);
--         StorageLive(_26);
--         _26 = _1;
+          StorageLive(_26);
+          _26 = _1;
 -         switchInt(move _26) -> [0: bb11, otherwise: bb9];
 +         switchInt(_1) -> [0: bb11, otherwise: bb9];
       }
   
       bb9: {
           StorageLive(_27);
--         StorageLive(_28);
--         StorageLive(_29);
--         _29 = _2;
--         StorageLive(_30);
--         _30 = _3;
+          StorageLive(_28);
+          StorageLive(_29);
+          _29 = _2;
+          StorageLive(_30);
+          _30 = _3;
 -         _28 = Add(move _29, move _30);
--         StorageDead(_30);
--         StorageDead(_29);
++         _28 = _23;
+          StorageDead(_30);
+          StorageDead(_29);
 -         _27 = opaque::<u8>(move _28) -> [return: bb10, unwind continue];
 +         _27 = opaque::<u8>(_23) -> [return: bb10, unwind continue];
       }
   
       bb10: {
--         StorageDead(_28);
+          StorageDead(_28);
           StorageDead(_27);
           _0 = const ();
           goto -> bb13;
@@ -171,27 +180,28 @@
   
       bb11: {
           StorageLive(_31);
--         StorageLive(_32);
--         StorageLive(_33);
--         _33 = _2;
--         StorageLive(_34);
--         _34 = _3;
+          StorageLive(_32);
+          StorageLive(_33);
+          _33 = _2;
+          StorageLive(_34);
+          _34 = _3;
 -         _32 = Add(move _33, move _34);
--         StorageDead(_34);
--         StorageDead(_33);
++         _32 = _23;
+          StorageDead(_34);
+          StorageDead(_33);
 -         _31 = opaque::<u8>(move _32) -> [return: bb12, unwind continue];
 +         _31 = opaque::<u8>(_23) -> [return: bb12, unwind continue];
       }
   
       bb12: {
--         StorageDead(_32);
+          StorageDead(_32);
           StorageDead(_31);
           _0 = const ();
           goto -> bb13;
       }
   
       bb13: {
--         StorageDead(_26);
+          StorageDead(_26);
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.references.GVN.panic-abort.diff b/tests/mir-opt/gvn.references.GVN.panic-abort.diff
index b7ad4ab1fd3..7799c611445 100644
--- a/tests/mir-opt/gvn.references.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.references.GVN.panic-abort.diff
@@ -20,6 +20,24 @@
       let mut _15: *mut impl Sized;
       let _16: ();
       let mut _17: *mut impl Sized;
+      let _18: &mut impl Sized;
+      let mut _20: S<&mut impl Sized>;
+      let mut _21: &mut impl Sized;
+      let _22: ();
+      let mut _23: &impl Sized;
+      let _24: ();
+      let mut _25: &mut impl Sized;
+      let _26: ();
+      let mut _27: *const impl Sized;
+      let _28: ();
+      let mut _29: *mut impl Sized;
+      scope 1 {
+          debug r => _18;
+          let _19: &mut impl Sized;
+          scope 2 {
+              debug s => _19;
+          }
+      }
   
       bb0: {
           StorageLive(_2);
@@ -94,11 +112,68 @@
       bb8: {
           StorageDead(_17);
           StorageDead(_16);
-          _0 = const ();
-          drop(_1) -> [return: bb9, unwind unreachable];
+-         StorageLive(_18);
++         nop;
+          _18 = &mut _1;
+          StorageLive(_19);
+          StorageLive(_20);
+          StorageLive(_21);
+-         _21 = move _18;
+-         _20 = S::<&mut impl Sized>(move _21);
++         _21 = _18;
++         _20 = S::<&mut impl Sized>(_18);
+          StorageDead(_21);
+-         _19 = move (_20.0: &mut impl Sized);
++         _19 = _18;
+          StorageDead(_20);
+          StorageLive(_22);
+          StorageLive(_23);
+-         _23 = &(*_19);
++         _23 = &(*_18);
+          _22 = opaque::<&impl Sized>(move _23) -> [return: bb9, unwind unreachable];
       }
   
       bb9: {
+          StorageDead(_23);
+          StorageDead(_22);
+          StorageLive(_24);
+          StorageLive(_25);
+-         _25 = &mut (*_19);
++         _25 = &mut (*_18);
+          _24 = opaque::<&mut impl Sized>(move _25) -> [return: bb10, unwind unreachable];
+      }
+  
+      bb10: {
+          StorageDead(_25);
+          StorageDead(_24);
+          StorageLive(_26);
+          StorageLive(_27);
+-         _27 = &raw const (*_19);
++         _27 = &raw const (*_18);
+          _26 = opaque::<*const impl Sized>(move _27) -> [return: bb11, unwind unreachable];
+      }
+  
+      bb11: {
+          StorageDead(_27);
+          StorageDead(_26);
+          StorageLive(_28);
+          StorageLive(_29);
+-         _29 = &raw mut (*_19);
++         _29 = &raw mut (*_18);
+          _28 = opaque::<*mut impl Sized>(move _29) -> [return: bb12, unwind unreachable];
+      }
+  
+      bb12: {
+          StorageDead(_29);
+          StorageDead(_28);
+          _0 = const ();
+          StorageDead(_19);
+-         StorageDead(_18);
++         nop;
+          drop(_1) -> [return: bb13, unwind unreachable];
+      }
+  
+      bb13: {
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.references.GVN.panic-unwind.diff b/tests/mir-opt/gvn.references.GVN.panic-unwind.diff
index 08ed4c629a6..880e7913fa9 100644
--- a/tests/mir-opt/gvn.references.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.references.GVN.panic-unwind.diff
@@ -20,12 +20,30 @@
       let mut _15: *mut impl Sized;
       let _16: ();
       let mut _17: *mut impl Sized;
+      let _18: &mut impl Sized;
+      let mut _20: S<&mut impl Sized>;
+      let mut _21: &mut impl Sized;
+      let _22: ();
+      let mut _23: &impl Sized;
+      let _24: ();
+      let mut _25: &mut impl Sized;
+      let _26: ();
+      let mut _27: *const impl Sized;
+      let _28: ();
+      let mut _29: *mut impl Sized;
+      scope 1 {
+          debug r => _18;
+          let _19: &mut impl Sized;
+          scope 2 {
+              debug s => _19;
+          }
+      }
   
       bb0: {
           StorageLive(_2);
           StorageLive(_3);
           _3 = &_1;
-          _2 = opaque::<&impl Sized>(move _3) -> [return: bb1, unwind: bb10];
+          _2 = opaque::<&impl Sized>(move _3) -> [return: bb1, unwind: bb14];
       }
   
       bb1: {
@@ -34,7 +52,7 @@
           StorageLive(_4);
           StorageLive(_5);
           _5 = &_1;
-          _4 = opaque::<&impl Sized>(move _5) -> [return: bb2, unwind: bb10];
+          _4 = opaque::<&impl Sized>(move _5) -> [return: bb2, unwind: bb14];
       }
   
       bb2: {
@@ -43,7 +61,7 @@
           StorageLive(_6);
           StorageLive(_7);
           _7 = &mut _1;
-          _6 = opaque::<&mut impl Sized>(move _7) -> [return: bb3, unwind: bb10];
+          _6 = opaque::<&mut impl Sized>(move _7) -> [return: bb3, unwind: bb14];
       }
   
       bb3: {
@@ -52,7 +70,7 @@
           StorageLive(_8);
           StorageLive(_9);
           _9 = &mut _1;
-          _8 = opaque::<&mut impl Sized>(move _9) -> [return: bb4, unwind: bb10];
+          _8 = opaque::<&mut impl Sized>(move _9) -> [return: bb4, unwind: bb14];
       }
   
       bb4: {
@@ -61,7 +79,7 @@
           StorageLive(_10);
           StorageLive(_11);
           _11 = &raw const _1;
-          _10 = opaque::<*const impl Sized>(move _11) -> [return: bb5, unwind: bb10];
+          _10 = opaque::<*const impl Sized>(move _11) -> [return: bb5, unwind: bb14];
       }
   
       bb5: {
@@ -70,7 +88,7 @@
           StorageLive(_12);
           StorageLive(_13);
           _13 = &raw const _1;
-          _12 = opaque::<*const impl Sized>(move _13) -> [return: bb6, unwind: bb10];
+          _12 = opaque::<*const impl Sized>(move _13) -> [return: bb6, unwind: bb14];
       }
   
       bb6: {
@@ -79,7 +97,7 @@
           StorageLive(_14);
           StorageLive(_15);
           _15 = &raw mut _1;
-          _14 = opaque::<*mut impl Sized>(move _15) -> [return: bb7, unwind: bb10];
+          _14 = opaque::<*mut impl Sized>(move _15) -> [return: bb7, unwind: bb14];
       }
   
       bb7: {
@@ -88,25 +106,82 @@
           StorageLive(_16);
           StorageLive(_17);
           _17 = &raw mut _1;
-          _16 = opaque::<*mut impl Sized>(move _17) -> [return: bb8, unwind: bb10];
+          _16 = opaque::<*mut impl Sized>(move _17) -> [return: bb8, unwind: bb14];
       }
   
       bb8: {
           StorageDead(_17);
           StorageDead(_16);
-          _0 = const ();
-          drop(_1) -> [return: bb9, unwind: bb11];
+-         StorageLive(_18);
++         nop;
+          _18 = &mut _1;
+          StorageLive(_19);
+          StorageLive(_20);
+          StorageLive(_21);
+-         _21 = move _18;
+-         _20 = S::<&mut impl Sized>(move _21);
++         _21 = _18;
++         _20 = S::<&mut impl Sized>(_18);
+          StorageDead(_21);
+-         _19 = move (_20.0: &mut impl Sized);
++         _19 = _18;
+          StorageDead(_20);
+          StorageLive(_22);
+          StorageLive(_23);
+-         _23 = &(*_19);
++         _23 = &(*_18);
+          _22 = opaque::<&impl Sized>(move _23) -> [return: bb9, unwind: bb14];
       }
   
       bb9: {
+          StorageDead(_23);
+          StorageDead(_22);
+          StorageLive(_24);
+          StorageLive(_25);
+-         _25 = &mut (*_19);
++         _25 = &mut (*_18);
+          _24 = opaque::<&mut impl Sized>(move _25) -> [return: bb10, unwind: bb14];
+      }
+  
+      bb10: {
+          StorageDead(_25);
+          StorageDead(_24);
+          StorageLive(_26);
+          StorageLive(_27);
+-         _27 = &raw const (*_19);
++         _27 = &raw const (*_18);
+          _26 = opaque::<*const impl Sized>(move _27) -> [return: bb11, unwind: bb14];
+      }
+  
+      bb11: {
+          StorageDead(_27);
+          StorageDead(_26);
+          StorageLive(_28);
+          StorageLive(_29);
+-         _29 = &raw mut (*_19);
++         _29 = &raw mut (*_18);
+          _28 = opaque::<*mut impl Sized>(move _29) -> [return: bb12, unwind: bb14];
+      }
+  
+      bb12: {
+          StorageDead(_29);
+          StorageDead(_28);
+          _0 = const ();
+          StorageDead(_19);
+-         StorageDead(_18);
++         nop;
+          drop(_1) -> [return: bb13, unwind: bb15];
+      }
+  
+      bb13: {
           return;
       }
   
-      bb10 (cleanup): {
-          drop(_1) -> [return: bb11, unwind terminate(cleanup)];
+      bb14 (cleanup): {
+          drop(_1) -> [return: bb15, unwind terminate(cleanup)];
       }
   
-      bb11 (cleanup): {
+      bb15 (cleanup): {
           resume;
       }
   }
diff --git a/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff b/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff
new file mode 100644
index 00000000000..37915f8578d
--- /dev/null
+++ b/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff
@@ -0,0 +1,79 @@
+- // MIR for `repeat` before GVN
++ // MIR for `repeat` after GVN
+  
+  fn repeat() -> () {
+      let mut _0: ();
+      let _1: i32;
+      let mut _3: i32;
+      let mut _4: i32;
+      let mut _5: i32;
+      let mut _6: i32;
+      let mut _7: i32;
+      let mut _8: i32;
+      let mut _9: i32;
+      let mut _10: i32;
+      let mut _11: i32;
+      let mut _12: i32;
+      scope 1 {
+          debug val => _1;
+          let _2: [i32; 10];
+          scope 2 {
+              debug array => _2;
+          }
+      }
+  
+      bb0: {
+-         StorageLive(_1);
++         nop;
+          _1 = const 5_i32;
+          StorageLive(_2);
+          StorageLive(_3);
+-         _3 = _1;
++         _3 = const 5_i32;
+          StorageLive(_4);
+-         _4 = _1;
++         _4 = const 5_i32;
+          StorageLive(_5);
+-         _5 = _1;
++         _5 = const 5_i32;
+          StorageLive(_6);
+-         _6 = _1;
++         _6 = const 5_i32;
+          StorageLive(_7);
+-         _7 = _1;
++         _7 = const 5_i32;
+          StorageLive(_8);
+-         _8 = _1;
++         _8 = const 5_i32;
+          StorageLive(_9);
+-         _9 = _1;
++         _9 = const 5_i32;
+          StorageLive(_10);
+-         _10 = _1;
++         _10 = const 5_i32;
+          StorageLive(_11);
+-         _11 = _1;
++         _11 = const 5_i32;
+          StorageLive(_12);
+-         _12 = _1;
+-         _2 = [move _3, move _4, move _5, move _6, move _7, move _8, move _9, move _10, move _11, move _12];
++         _12 = const 5_i32;
++         _2 = [const 5_i32; 10];
+          StorageDead(_12);
+          StorageDead(_11);
+          StorageDead(_10);
+          StorageDead(_9);
+          StorageDead(_8);
+          StorageDead(_7);
+          StorageDead(_6);
+          StorageDead(_5);
+          StorageDead(_4);
+          StorageDead(_3);
+          _0 = const ();
+          StorageDead(_2);
+-         StorageDead(_1);
++         nop;
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff b/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff
new file mode 100644
index 00000000000..37915f8578d
--- /dev/null
+++ b/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff
@@ -0,0 +1,79 @@
+- // MIR for `repeat` before GVN
++ // MIR for `repeat` after GVN
+  
+  fn repeat() -> () {
+      let mut _0: ();
+      let _1: i32;
+      let mut _3: i32;
+      let mut _4: i32;
+      let mut _5: i32;
+      let mut _6: i32;
+      let mut _7: i32;
+      let mut _8: i32;
+      let mut _9: i32;
+      let mut _10: i32;
+      let mut _11: i32;
+      let mut _12: i32;
+      scope 1 {
+          debug val => _1;
+          let _2: [i32; 10];
+          scope 2 {
+              debug array => _2;
+          }
+      }
+  
+      bb0: {
+-         StorageLive(_1);
++         nop;
+          _1 = const 5_i32;
+          StorageLive(_2);
+          StorageLive(_3);
+-         _3 = _1;
++         _3 = const 5_i32;
+          StorageLive(_4);
+-         _4 = _1;
++         _4 = const 5_i32;
+          StorageLive(_5);
+-         _5 = _1;
++         _5 = const 5_i32;
+          StorageLive(_6);
+-         _6 = _1;
++         _6 = const 5_i32;
+          StorageLive(_7);
+-         _7 = _1;
++         _7 = const 5_i32;
+          StorageLive(_8);
+-         _8 = _1;
++         _8 = const 5_i32;
+          StorageLive(_9);
+-         _9 = _1;
++         _9 = const 5_i32;
+          StorageLive(_10);
+-         _10 = _1;
++         _10 = const 5_i32;
+          StorageLive(_11);
+-         _11 = _1;
++         _11 = const 5_i32;
+          StorageLive(_12);
+-         _12 = _1;
+-         _2 = [move _3, move _4, move _5, move _6, move _7, move _8, move _9, move _10, move _11, move _12];
++         _12 = const 5_i32;
++         _2 = [const 5_i32; 10];
+          StorageDead(_12);
+          StorageDead(_11);
+          StorageDead(_10);
+          StorageDead(_9);
+          StorageDead(_8);
+          StorageDead(_7);
+          StorageDead(_6);
+          StorageDead(_5);
+          StorageDead(_4);
+          StorageDead(_3);
+          _0 = const ();
+          StorageDead(_2);
+-         StorageDead(_1);
++         nop;
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff b/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff
index 4c29523d6b2..d937902e891 100644
--- a/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff
@@ -23,11 +23,11 @@
   
       bb0: {
           StorageLive(_3);
--         StorageLive(_4);
--         _4 = _1;
+          StorageLive(_4);
+          _4 = _1;
 -         _3 = [move _4; N];
--         StorageDead(_4);
 +         _3 = [_1; N];
+          StorageDead(_4);
           StorageLive(_5);
           StorageLive(_6);
           StorageLive(_7);
@@ -40,8 +40,10 @@
       }
   
       bb1: {
-          _6 = _3[_7];
-          _5 = opaque::<T>(move _6) -> [return: bb2, unwind unreachable];
+-         _6 = _3[_7];
+-         _5 = opaque::<T>(move _6) -> [return: bb2, unwind unreachable];
++         _6 = _1;
++         _5 = opaque::<T>(_1) -> [return: bb2, unwind unreachable];
       }
   
       bb2: {
@@ -55,13 +57,16 @@
 -         _13 = Len(_3);
 -         _14 = Lt(_12, _13);
 -         assert(move _14, "index out of bounds: the length is {} but the index is {}", move _13, _12) -> [success: bb3, unwind unreachable];
++         _13 = _8;
 +         _14 = Lt(_2, _8);
 +         assert(move _14, "index out of bounds: the length is {} but the index is {}", _8, _2) -> [success: bb3, unwind unreachable];
       }
   
       bb3: {
-          _11 = _3[_12];
-          _10 = opaque::<T>(move _11) -> [return: bb4, unwind unreachable];
+-         _11 = _3[_12];
+-         _10 = opaque::<T>(move _11) -> [return: bb4, unwind unreachable];
++         _11 = _1;
++         _10 = opaque::<T>(_1) -> [return: bb4, unwind unreachable];
       }
   
       bb4: {
diff --git a/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff b/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff
index e44f54cf3cf..dd4d24b12ea 100644
--- a/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff
@@ -23,11 +23,11 @@
   
       bb0: {
           StorageLive(_3);
--         StorageLive(_4);
--         _4 = _1;
+          StorageLive(_4);
+          _4 = _1;
 -         _3 = [move _4; N];
--         StorageDead(_4);
 +         _3 = [_1; N];
+          StorageDead(_4);
           StorageLive(_5);
           StorageLive(_6);
           StorageLive(_7);
@@ -40,8 +40,10 @@
       }
   
       bb1: {
-          _6 = _3[_7];
-          _5 = opaque::<T>(move _6) -> [return: bb2, unwind continue];
+-         _6 = _3[_7];
+-         _5 = opaque::<T>(move _6) -> [return: bb2, unwind continue];
++         _6 = _1;
++         _5 = opaque::<T>(_1) -> [return: bb2, unwind continue];
       }
   
       bb2: {
@@ -55,13 +57,16 @@
 -         _13 = Len(_3);
 -         _14 = Lt(_12, _13);
 -         assert(move _14, "index out of bounds: the length is {} but the index is {}", move _13, _12) -> [success: bb3, unwind continue];
++         _13 = _8;
 +         _14 = Lt(_2, _8);
 +         assert(move _14, "index out of bounds: the length is {} but the index is {}", _8, _2) -> [success: bb3, unwind continue];
       }
   
       bb3: {
-          _11 = _3[_12];
-          _10 = opaque::<T>(move _11) -> [return: bb4, unwind continue];
+-         _11 = _3[_12];
+-         _10 = opaque::<T>(move _11) -> [return: bb4, unwind continue];
++         _11 = _1;
++         _10 = opaque::<T>(_1) -> [return: bb4, unwind continue];
       }
   
       bb4: {
diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs
index fd24edc676c..10a66ced026 100644
--- a/tests/mir-opt/gvn.rs
+++ b/tests/mir-opt/gvn.rs
@@ -1,56 +1,133 @@
-// skip-filecheck
 // unit-test: GVN
 // EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// only-64bit
 
 #![feature(raw_ref_op)]
 #![feature(rustc_attrs)]
+#![feature(custom_mir)]
+#![feature(core_intrinsics)]
 #![allow(unconditional_panic)]
 
+use std::intrinsics::mir::*;
+use std::mem::transmute;
+
 struct S<T>(T);
 
 fn subexpression_elimination(x: u64, y: u64, mut z: u64) {
+    // CHECK-LABEL: fn subexpression_elimination(
+
+    // CHECK: [[add:_.*]] = Add(_1, _2);
+    // CHECK: opaque::<u64>([[add]])
     opaque(x + y);
+    // CHECK: [[mul:_.*]] = Mul(_1, _2);
+    // CHECK: opaque::<u64>([[mul]])
     opaque(x * y);
+    // CHECK: [[sub:_.*]] = Sub(_1, _2);
+    // CHECK: opaque::<u64>([[sub]])
     opaque(x - y);
+    // CHECK: [[div:_.*]] = Div(_1, _2);
+    // CHECK: opaque::<u64>([[div]])
     opaque(x / y);
+    // CHECK: [[rem:_.*]] = Rem(_1, _2);
+    // CHECK: opaque::<u64>([[rem]])
     opaque(x % y);
+    // CHECK: [[and:_.*]] = BitAnd(_1, _2);
+    // CHECK: opaque::<u64>([[and]])
     opaque(x & y);
+    // CHECK: [[or:_.*]] = BitOr(_1, _2);
+    // CHECK: opaque::<u64>([[or]])
     opaque(x | y);
+    // CHECK: [[xor:_.*]] = BitXor(_1, _2);
+    // CHECK: opaque::<u64>([[xor]])
     opaque(x ^ y);
+    // CHECK: [[shl:_.*]] = Shl(_1, _2);
+    // CHECK: opaque::<u64>([[shl]])
     opaque(x << y);
+    // CHECK: [[shr:_.*]] = Shr(_1, _2);
+    // CHECK: opaque::<u64>([[shr]])
     opaque(x >> y);
+    // CHECK: [[int:_.*]] = _1 as u32 (IntToInt);
+    // CHECK: opaque::<u32>([[int]])
     opaque(x as u32);
+    // CHECK: [[float:_.*]] = _1 as f32 (IntToFloat);
+    // CHECK: opaque::<f32>([[float]])
     opaque(x as f32);
+    // CHECK: [[wrap:_.*]] = S::<u64>(_1);
+    // CHECK: opaque::<S<u64>>([[wrap]])
     opaque(S(x));
+    // CHECK: opaque::<u64>(_1)
     opaque(S(x).0);
 
     // Those are duplicates to substitute somehow.
-    opaque((x + y) + z);
-    opaque((x * y) + z);
-    opaque((x - y) + z);
-    opaque((x / y) + z);
-    opaque((x % y) + z);
-    opaque((x & y) + z);
-    opaque((x | y) + z);
-    opaque((x ^ y) + z);
-    opaque((x << y) + z);
-    opaque((x >> y) + z);
+    // CHECK: opaque::<u64>([[add]])
+    opaque(x + y);
+    // CHECK: opaque::<u64>([[mul]])
+    opaque(x * y);
+    // CHECK: opaque::<u64>([[sub]])
+    opaque(x - y);
+    // CHECK: opaque::<u64>([[div]])
+    opaque(x / y);
+    // CHECK: opaque::<u64>([[rem]])
+    opaque(x % y);
+    // CHECK: opaque::<u64>([[and]])
+    opaque(x & y);
+    // CHECK: opaque::<u64>([[or]])
+    opaque(x | y);
+    // CHECK: opaque::<u64>([[xor]])
+    opaque(x ^ y);
+    // CHECK: opaque::<u64>([[shl]])
+    opaque(x << y);
+    // CHECK: opaque::<u64>([[shr]])
+    opaque(x >> y);
+    // CHECK: opaque::<u32>([[int]])
+    opaque(x as u32);
+    // CHECK: opaque::<f32>([[float]])
+    opaque(x as f32);
+    // CHECK: opaque::<S<u64>>([[wrap]])
     opaque(S(x));
+    // CHECK: opaque::<u64>(_1)
     opaque(S(x).0);
 
+    // We can substitute through a complex expression.
+    // CHECK: [[compound:_.*]] = Sub([[mul]], _2);
+    // CHECK: opaque::<u64>([[compound]])
+    // CHECK: opaque::<u64>([[compound]])
+    opaque((x * y) - y);
+    opaque((x * y) - y);
+
     // We can substitute through an immutable reference too.
+    // CHECK: [[ref:_.*]] = &_3;
+    // CHECK: [[deref:_.*]] = (*[[ref]]);
+    // CHECK: [[addref:_.*]] = Add([[deref]], _1);
+    // CHECK: opaque::<u64>([[addref]])
+    // CHECK: opaque::<u64>([[addref]])
     let a = &z;
     opaque(*a + x);
     opaque(*a + x);
 
     // But not through a mutable reference or a pointer.
+    // CHECK: [[mut:_.*]] = &mut _3;
+    // CHECK: [[addmut:_.*]] = Add(
+    // CHECK: opaque::<u64>(move [[addmut]])
+    // CHECK: [[addmut2:_.*]] = Add(
+    // CHECK: opaque::<u64>(move [[addmut2]])
     let b = &mut z;
     opaque(*b + x);
     opaque(*b + x);
     unsafe {
+        // CHECK: [[raw:_.*]] = &raw const _3;
+        // CHECK: [[addraw:_.*]] = Add(
+        // CHECK: opaque::<u64>(move [[addraw]])
+        // CHECK: [[addraw2:_.*]] = Add(
+        // CHECK: opaque::<u64>(move [[addraw2]])
         let c = &raw const z;
         opaque(*c + x);
         opaque(*c + x);
+        // CHECK: [[ptr:_.*]] = &raw mut _3;
+        // CHECK: [[addptr:_.*]] = Add(
+        // CHECK: opaque::<u64>(move [[addptr]])
+        // CHECK: [[addptr2:_.*]] = Add(
+        // CHECK: opaque::<u64>(move [[addptr2]])
         let d = &raw mut z;
         opaque(*d + x);
         opaque(*d + x);
@@ -58,13 +135,21 @@ fn subexpression_elimination(x: u64, y: u64, mut z: u64) {
 
     // We can substitute again, but not with the earlier computations.
     // Important: `e` is not `a`!
+    // CHECK: [[ref2:_.*]] = &_3;
+    // CHECK: [[deref2:_.*]] = (*[[ref2]]);
+    // CHECK: [[addref2:_.*]] = Add([[deref2]], _1);
+    // CHECK: opaque::<u64>([[addref2]])
+    // CHECK: opaque::<u64>([[addref2]])
     let e = &z;
     opaque(*e + x);
     opaque(*e + x);
-
 }
 
 fn wrap_unwrap<T: Copy>(x: T) -> T {
+    // CHECK-LABEL: fn wrap_unwrap(
+    // CHECK: [[some:_.*]] = Option::<T>::Some(_1);
+    // CHECK: switchInt(const 1_isize)
+    // CHECK: _0 = _1;
     match Some(x) {
         Some(y) => y,
         None => panic!(),
@@ -72,163 +157,464 @@ fn wrap_unwrap<T: Copy>(x: T) -> T {
 }
 
 fn repeated_index<T: Copy, const N: usize>(x: T, idx: usize) {
+    // CHECK-LABEL: fn repeated_index(
+    // CHECK: [[a:_.*]] = [_1; N];
     let a = [x; N];
+    // CHECK: opaque::<T>(_1)
     opaque(a[0]);
+    // CHECK: opaque::<T>(_1)
     opaque(a[idx]);
 }
 
+/// Verify symbolic integer arithmetic simplifications.
 fn arithmetic(x: u64) {
+    // CHECK-LABEL: fn arithmetic(
+    // CHECK: [[add:_.*]] = Add(_1, const 0_u64);
+    // CHECK: opaque::<u64>(move [[add]])
     opaque(x + 0);
+    // CHECK: [[sub:_.*]] = Sub(_1, const 0_u64);
+    // CHECK: opaque::<u64>(move [[sub]])
     opaque(x - 0);
+    // CHECK: [[mul0:_.*]] = Mul(_1, const 0_u64);
+    // CHECK: opaque::<u64>(move [[mul0]])
     opaque(x * 0);
+    // CHECK: [[mul1:_.*]] = Mul(_1, const 1_u64);
+    // CHECK: opaque::<u64>(move [[mul1]])
     opaque(x * 1);
+    // CHECK: [[div0:_.*]] = Div(_1, const 0_u64);
+    // CHECK: opaque::<u64>(move [[div0]])
     opaque(x / 0);
+    // CHECK: [[div1:_.*]] = Div(_1, const 1_u64);
+    // CHECK: opaque::<u64>(move [[div1]])
     opaque(x / 1);
+    // CHECK: [[zdiv:_.*]] = Div(const 0_u64, _1);
+    // CHECK: opaque::<u64>(move [[zdiv]])
     opaque(0 / x);
+    // CHECK: [[odiv:_.*]] = Div(const 1_u64, _1);
+    // CHECK: opaque::<u64>(move [[odiv]])
     opaque(1 / x);
+    // CHECK: [[rem0:_.*]] = Rem(_1, const 0_u64);
+    // CHECK: opaque::<u64>(move [[rem0]])
     opaque(x % 0);
+    // CHECK: [[rem1:_.*]] = Rem(_1, const 1_u64);
+    // CHECK: opaque::<u64>(move [[rem1]])
     opaque(x % 1);
+    // CHECK: [[zrem:_.*]] = Rem(const 0_u64, _1);
+    // CHECK: opaque::<u64>(move [[zrem]])
     opaque(0 % x);
+    // CHECK: [[orem:_.*]] = Rem(const 1_u64, _1);
+    // CHECK: opaque::<u64>(move [[orem]])
     opaque(1 % x);
+    // CHECK: [[and:_.*]] = BitAnd(_1, const 0_u64);
+    // CHECK: opaque::<u64>(move [[and]])
     opaque(x & 0);
+    // CHECK: [[or:_.*]] = BitOr(_1, const 0_u64);
+    // CHECK: opaque::<u64>(move [[or]])
     opaque(x | 0);
+    // CHECK: [[xor:_.*]] = BitXor(_1, const 0_u64);
+    // CHECK: opaque::<u64>(move [[xor]])
     opaque(x ^ 0);
+    // CHECK: [[shr:_.*]] = Shr(_1, const 0_i32);
+    // CHECK: opaque::<u64>(move [[shr]])
     opaque(x >> 0);
+    // CHECK: [[shl:_.*]] = Shl(_1, const 0_i32);
+    // CHECK: opaque::<u64>(move [[shl]])
     opaque(x << 0);
 }
 
+fn comparison(x: u64, y: u64) {
+    // CHECK-LABEL: fn comparison(
+    // CHECK: [[eqxx:_.*]] = Eq(_1, _1);
+    // CHECK: opaque::<bool>(move [[eqxx]])
+    opaque(x == x);
+    // CHECK: [[nexx:_.*]] = Ne(_1, _1);
+    // CHECK: opaque::<bool>(move [[nexx]])
+    opaque(x != x);
+    // CHECK: [[eqxy:_.*]] = Eq(_1, _2);
+    // CHECK: opaque::<bool>(move [[eqxy]])
+    opaque(x == y);
+    // CHECK: [[nexy:_.*]] = Ne(_1, _2);
+    // CHECK: opaque::<bool>(move [[nexy]])
+    opaque(x != y);
+}
+
+/// Verify symbolic integer arithmetic simplifications on checked ops.
 #[rustc_inherit_overflow_checks]
 fn arithmetic_checked(x: u64) {
+    // CHECK-LABEL: fn arithmetic_checked(
+    // CHECK: [[cadd:_.*]] = CheckedAdd(_1, const 0_u64);
+    // CHECK: [[add:_.*]] = move ([[cadd]].0: u64);
+    // CHECK: opaque::<u64>(move [[add]])
     opaque(x + 0);
+    // CHECK: [[csub:_.*]] = CheckedSub(_1, const 0_u64);
+    // CHECK: [[sub:_.*]] = move ([[csub]].0: u64);
+    // CHECK: opaque::<u64>(move [[sub]])
     opaque(x - 0);
+    // CHECK: [[cmul0:_.*]] = CheckedMul(_1, const 0_u64);
+    // CHECK: [[mul0:_.*]] = move ([[cmul0]].0: u64);
+    // CHECK: opaque::<u64>(move [[mul0]])
     opaque(x * 0);
+    // CHECK: [[cmul1:_.*]] = CheckedMul(_1, const 1_u64);
+    // CHECK: [[mul1:_.*]] = move ([[cmul1]].0: u64);
+    // CHECK: opaque::<u64>(move [[mul1]])
     opaque(x * 1);
-    opaque(x / 0);
-    opaque(x / 1);
-    opaque(0 / x);
-    opaque(1 / x);
-    opaque(x % 0);
-    opaque(x % 1);
-    opaque(0 % x);
-    opaque(1 % x);
-    opaque(x & 0);
-    opaque(x | 0);
-    opaque(x ^ 0);
-    opaque(x >> 0);
-    opaque(x << 0);
 }
 
+/// Verify that we do not apply arithmetic simplifications on floats.
 fn arithmetic_float(x: f64) {
+    // CHECK-LABEL: fn arithmetic_float(
+    // CHECK: [[add:_.*]] = Add(_1, const 0f64);
+    // CHECK: opaque::<f64>(move [[add]])
     opaque(x + 0.);
+    // CHECK: [[sub:_.*]] = Sub(_1, const 0f64);
+    // CHECK: opaque::<f64>(move [[sub]])
     opaque(x - 0.);
+    // CHECK: [[mul:_.*]] = Mul(_1, const 0f64);
+    // CHECK: opaque::<f64>(move [[mul]])
     opaque(x * 0.);
+    // CHECK: [[div0:_.*]] = Div(_1, const 0f64);
+    // CHECK: opaque::<f64>(move [[div0]])
     opaque(x / 0.);
+    // CHECK: [[zdiv:_.*]] = Div(const 0f64, _1);
+    // CHECK: opaque::<f64>(move [[zdiv]])
     opaque(0. / x);
+    // CHECK: [[rem0:_.*]] = Rem(_1, const 0f64);
+    // CHECK: opaque::<f64>(move [[rem0]])
     opaque(x % 0.);
+    // CHECK: [[zrem:_.*]] = Rem(const 0f64, _1);
+    // CHECK: opaque::<f64>(move [[zrem]])
     opaque(0. % x);
     // Those are not simplifiable to `true`/`false`, thanks to NaNs.
+    // CHECK: [[eq:_.*]] = Eq(_1, _1);
+    // CHECK: opaque::<bool>(move [[eq]])
     opaque(x == x);
+    // CHECK: [[ne:_.*]] = Ne(_1, _1);
+    // CHECK: opaque::<bool>(move [[ne]])
     opaque(x != x);
 }
 
 fn cast() {
+    // CHECK-LABEL: fn cast(
     let i = 1_i64;
     let u = 1_u64;
     let f = 1_f64;
+    // CHECK: opaque::<u8>(const 1_u8)
     opaque(i as u8);
+    // CHECK: opaque::<u16>(const 1_u16)
     opaque(i as u16);
+    // CHECK: opaque::<u32>(const 1_u32)
     opaque(i as u32);
+    // CHECK: opaque::<u64>(const 1_u64)
     opaque(i as u64);
+    // CHECK: opaque::<i8>(const 1_i8)
     opaque(i as i8);
+    // CHECK: opaque::<i16>(const 1_i16)
     opaque(i as i16);
+    // CHECK: opaque::<i32>(const 1_i32)
     opaque(i as i32);
+    // CHECK: opaque::<i64>(const 1_i64)
     opaque(i as i64);
+    // CHECK: opaque::<f32>(const 1f32)
     opaque(i as f32);
+    // CHECK: opaque::<f64>(const 1f64)
     opaque(i as f64);
+    // CHECK: opaque::<u8>(const 1_u8)
     opaque(u as u8);
+    // CHECK: opaque::<u16>(const 1_u16)
     opaque(u as u16);
+    // CHECK: opaque::<u32>(const 1_u32)
     opaque(u as u32);
+    // CHECK: opaque::<u64>(const 1_u64)
     opaque(u as u64);
+    // CHECK: opaque::<i8>(const 1_i8)
     opaque(u as i8);
+    // CHECK: opaque::<i16>(const 1_i16)
     opaque(u as i16);
+    // CHECK: opaque::<i32>(const 1_i32)
     opaque(u as i32);
+    // CHECK: opaque::<i64>(const 1_i64)
     opaque(u as i64);
+    // CHECK: opaque::<f32>(const 1f32)
     opaque(u as f32);
+    // CHECK: opaque::<f64>(const 1f64)
     opaque(u as f64);
+    // CHECK: opaque::<u8>(const 1_u8)
     opaque(f as u8);
+    // CHECK: opaque::<u16>(const 1_u16)
     opaque(f as u16);
+    // CHECK: opaque::<u32>(const 1_u32)
     opaque(f as u32);
+    // CHECK: opaque::<u64>(const 1_u64)
     opaque(f as u64);
+    // CHECK: opaque::<i8>(const 1_i8)
     opaque(f as i8);
+    // CHECK: opaque::<i16>(const 1_i16)
     opaque(f as i16);
+    // CHECK: opaque::<i32>(const 1_i32)
     opaque(f as i32);
+    // CHECK: opaque::<i64>(const 1_i64)
     opaque(f as i64);
+    // CHECK: opaque::<f32>(const 1f32)
     opaque(f as f32);
+    // CHECK: opaque::<f64>(const 1f64)
     opaque(f as f64);
 }
 
 fn multiple_branches(t: bool, x: u8, y: u8) {
+    // CHECK-LABEL: fn multiple_branches(
+    // CHECK: switchInt(_1) -> [0: [[bbf:bb.*]], otherwise: [[bbt:bb.*]]];
     if t {
-        opaque(x + y); // a
-        opaque(x + y); // should reuse a
+        // CHECK: [[bbt]]: {
+        // CHECK: [[a:_.*]] = Add(_2, _3);
+        // CHECK: opaque::<u8>([[a]])
+        // CHECK: opaque::<u8>([[a]])
+        // CHECK: goto -> [[bbc:bb.*]];
+        opaque(x + y);
+        opaque(x + y);
     } else {
-        opaque(x + y); // b
-        opaque(x + y); // shoud reuse b
+        // CHECK: [[bbf]]: {
+        // CHECK: [[b:_.*]] = Add(_2, _3);
+        // CHECK: opaque::<u8>([[b]])
+        // CHECK: opaque::<u8>([[b]])
+        // CHECK: goto -> [[bbc:bb.*]];
+        opaque(x + y);
+        opaque(x + y);
     }
-    opaque(x + y); // c
+    // Neither `a` nor `b` dominate `c`, so we cannot reuse any of them.
+    // CHECK: [[bbc]]: {
+    // CHECK: [[c:_.*]] = Add(_2, _3);
+    // CHECK: opaque::<u8>([[c]])
+    opaque(x + y);
+
+    // `c` dominates both calls, so we can reuse it.
     if t {
-        opaque(x + y); // should reuse c
+        // CHECK: opaque::<u8>([[c]])
+        opaque(x + y);
     } else {
-        opaque(x + y); // should reuse c
+        // CHECK: opaque::<u8>([[c]])
+        opaque(x + y);
     }
 }
 
+/// Verify that we do not reuse a `&raw? mut?` rvalue.
 fn references(mut x: impl Sized) {
+    // CHECK-LABEL: fn references(
+    // CHECK: [[ref1:_.*]] = &_1;
+    // CHECK: opaque::<&impl Sized>(move [[ref1]])
     opaque(&x);
-    opaque(&x); // should not reuse a
+    // CHECK: [[ref2:_.*]] = &_1;
+    // CHECK: opaque::<&impl Sized>(move [[ref2]])
+    opaque(&x);
+    // CHECK: [[ref3:_.*]] = &mut _1;
+    // CHECK: opaque::<&mut impl Sized>(move [[ref3]])
+    opaque(&mut x);
+    // CHECK: [[ref4:_.*]] = &mut _1;
+    // CHECK: opaque::<&mut impl Sized>(move [[ref4]])
     opaque(&mut x);
-    opaque(&mut x); // should not reuse a
+    // CHECK: [[ref5:_.*]] = &raw const _1;
+    // CHECK: opaque::<*const impl Sized>(move [[ref5]])
     opaque(&raw const x);
-    opaque(&raw const x); // should not reuse a
+    // CHECK: [[ref6:_.*]] = &raw const _1;
+    // CHECK: opaque::<*const impl Sized>(move [[ref6]])
+    opaque(&raw const x);
+    // CHECK: [[ref7:_.*]] = &raw mut _1;
+    // CHECK: opaque::<*mut impl Sized>(move [[ref7]])
+    opaque(&raw mut x);
+    // CHECK: [[ref8:_.*]] = &raw mut _1;
+    // CHECK: opaque::<*mut impl Sized>(move [[ref8]])
     opaque(&raw mut x);
-    opaque(&raw mut x); // should not reuse a
+
+    let r = &mut x;
+    let s = S(r).0; // Obfuscate `r`. Following lines should still reborrow `r`.
+    // CHECK: [[ref9:_.*]] = &mut _1;
+    // CHECK: [[ref10:_.*]] = &(*[[ref9]]);
+    // CHECK: opaque::<&impl Sized>(move [[ref10]])
+    opaque(&*s);
+    // CHECK: [[ref11:_.*]] = &mut (*[[ref9]]);
+    // CHECK: opaque::<&mut impl Sized>(move [[ref11]])
+    opaque(&mut *s);
+    // CHECK: [[ref12:_.*]] = &raw const (*[[ref9]]);
+    // CHECK: opaque::<*const impl Sized>(move [[ref12]])
+    opaque(&raw const *s);
+    // CHECK: [[ref12:_.*]] = &raw mut (*[[ref9]]);
+    // CHECK: opaque::<*mut impl Sized>(move [[ref12]])
+    opaque(&raw mut *s);
 }
 
 fn dereferences(t: &mut u32, u: &impl Copy, s: &S<u32>) {
+    // CHECK-LABEL: fn dereferences(
+
+    // Do not reuse dereferences of `&mut`.
+    // CHECK: [[st1:_.*]] = (*_1);
+    // CHECK: opaque::<u32>(move [[st1]])
+    // CHECK: [[st2:_.*]] = (*_1);
+    // CHECK: opaque::<u32>(move [[st2]])
     opaque(*t);
-    opaque(*t); // this cannot reuse a, as x is &mut.
+    opaque(*t);
+
+    // Do not reuse dereferences of `*const`.
+    // CHECK: [[raw:_.*]] = &raw const (*_1);
+    // CHECK: [[st3:_.*]] = (*[[raw]]);
+    // CHECK: opaque::<u32>(move [[st3]])
+    // CHECK: [[st4:_.*]] = (*[[raw]]);
+    // CHECK: opaque::<u32>(move [[st4]])
     let z = &raw const *t;
     unsafe { opaque(*z) };
-    unsafe { opaque(*z) }; // this cannot reuse a, as x is *const.
+    unsafe { opaque(*z) };
+
+    // Do not reuse dereferences of `*mut`.
+    // CHECK: [[ptr:_.*]] = &raw mut (*_1);
+    // CHECK: [[st5:_.*]] = (*[[ptr]]);
+    // CHECK: opaque::<u32>(move [[st5]])
+    // CHECK: [[st6:_.*]] = (*[[ptr]]);
+    // CHECK: opaque::<u32>(move [[st6]])
     let z = &raw mut *t;
     unsafe { opaque(*z) };
-    unsafe { opaque(*z) }; // this cannot reuse a, as x is *mut.
+    unsafe { opaque(*z) };
+
+    // We can reuse dereferences of `&Freeze`.
+    // CHECK: [[ref:_.*]] = &(*_1);
+    // CHECK: [[st7:_.*]] = (*[[ref]]);
+    // CHECK: opaque::<u32>([[st7]])
+    // CHECK: opaque::<u32>([[st7]])
     let z = &*t;
     opaque(*z);
-    opaque(*z); // this can reuse, as `z` is immutable ref, Freeze and Copy.
-    opaque(&*z); // but not for a reborrow.
+    opaque(*z);
+    // But not in reborrows.
+    // CHECK: [[reborrow:_.*]] = &(*[[ref]]);
+    // CHECK: opaque::<&u32>(move [[reborrow]])
+    opaque(&*z);
+
+    // `*u` is not Freeze, so we cannot reuse.
+    // CHECK: [[st8:_.*]] = (*_2);
+    // CHECK: opaque::<impl Copy>(move [[st8]])
+    // CHECK: [[st9:_.*]] = (*_2);
+    // CHECK: opaque::<impl Copy>(move [[st9]])
     opaque(*u);
-    opaque(*u); // this cannot reuse, as `z` is not Freeze.
+    opaque(*u);
+
+    // `*s` is not Copy, by `(*s).0` is, so we can reuse.
+    // CHECK: [[st10:_.*]] = ((*_3).0: u32);
+    // CHECK: opaque::<u32>([[st10]])
+    // CHECK: opaque::<u32>([[st10]])
+    opaque(s.0);
     opaque(s.0);
-    opaque(s.0); // *s is not Copy, by (*s).0 is, so we can reuse.
 }
 
 fn slices() {
+    // CHECK-LABEL: fn slices(
+    // CHECK: {{_.*}} = const "
+    // CHECK-NOT: {{_.*}} = const "
     let s = "my favourite slice"; // This is a `Const::Slice` in MIR.
     opaque(s);
     let t = s; // This should be the same pointer, so cannot be a `Const::Slice`.
     opaque(t);
     assert_eq!(s.as_ptr(), t.as_ptr());
-    let u = unsafe { std::mem::transmute::<&str, &[u8]>(s) };
+    let u = unsafe { transmute::<&str, &[u8]>(s) };
     opaque(u);
     assert_eq!(s.as_ptr(), u.as_ptr());
 }
 
+#[custom_mir(dialect = "analysis")]
+fn duplicate_slice() -> (bool, bool) {
+    // CHECK-LABEL: fn duplicate_slice(
+    mir!(
+        let au: u128;
+        let bu: u128;
+        let cu: u128;
+        let du: u128;
+        let c: &str;
+        let d: &str;
+        {
+            // CHECK: [[a:_.*]] = (const "a",);
+            // CHECK: [[au:_.*]] = ([[a]].0: &str) as u128 (Transmute);
+            let a = ("a",);
+            Call(au = transmute::<_, u128>(a.0), bb1)
+        }
+        bb1 = {
+            // CHECK: [[c:_.*]] = identity::<&str>(([[a]].0: &str))
+            Call(c = identity(a.0), bb2)
+        }
+        bb2 = {
+            // CHECK: [[cu:_.*]] = [[c]] as u128 (Transmute);
+            Call(cu = transmute::<_, u128>(c), bb3)
+        }
+        bb3 = {
+            // This slice is different from `a.0`. Hence `bu` is not `au`.
+            // CHECK: [[b:_.*]] = const "a";
+            // CHECK: [[bu:_.*]] = [[b]] as u128 (Transmute);
+            let b = "a";
+            Call(bu = transmute::<_, u128>(b), bb4)
+        }
+        bb4 = {
+            // This returns a copy of `b`, which is not `a`.
+            // CHECK: [[d:_.*]] = identity::<&str>([[b]])
+            Call(d = identity(b), bb5)
+        }
+        bb5 = {
+            // CHECK: [[du:_.*]] = [[d]] as u128 (Transmute);
+            Call(du = transmute::<_, u128>(d), bb6)
+        }
+        bb6 = {
+            // `direct` must not fold to `true`, as `indirect` will not.
+            // CHECK: = Eq([[au]], [[bu]]);
+            // CHECK: = Eq([[cu]], [[du]]);
+            let direct = au == bu;
+            let indirect = cu == du;
+            RET = (direct, indirect);
+            Return()
+        }
+    )
+}
+
+fn repeat() {
+    // CHECK-LABEL: fn repeat(
+    // CHECK: = [const 5_i32; 10];
+    let val = 5;
+    let array = [val, val, val, val, val, val, val, val, val, val];
+}
+
+/// Verify that we do not merge fn pointers created by casts.
+fn fn_pointers() {
+    // CHECK-LABEL: fn fn_pointers(
+    // CHECK: [[f:_.*]] = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer
+    // CHECK: opaque::<fn(u8) -> u8>([[f]])
+    let f = identity as fn(u8) -> u8;
+    opaque(f);
+    // CHECK: [[g:_.*]] = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer
+    // CHECK: opaque::<fn(u8) -> u8>([[g]])
+    let g = identity as fn(u8) -> u8;
+    opaque(g);
+
+    // CHECK: [[cf:_.*]] = const {{.*}} as fn() (PointerCoercion(ClosureFnPointer
+    // CHECK: opaque::<fn()>([[cf]])
+    let closure = || {};
+    let cf = closure as fn();
+    opaque(cf);
+    // CHECK: [[cg:_.*]] = const {{.*}} as fn() (PointerCoercion(ClosureFnPointer
+    // CHECK: opaque::<fn()>([[cg]])
+    let cg = closure as fn();
+    opaque(cg);
+}
+
+/// Verify that we do not create a `ConstValue::Indirect` backed by a static's AllocId.
+#[custom_mir(dialect = "analysis")]
+fn indirect_static() {
+    static A: Option<u8> = None;
+
+    mir!({
+        let ptr = Static(A);
+        let out = Field::<u8>(Variant(*ptr, 1), 0);
+        Return()
+    })
+}
+
 fn main() {
     subexpression_elimination(2, 4, 5);
     wrap_unwrap(5);
     repeated_index::<u32, 7>(5, 3);
     arithmetic(5);
+    comparison(5, 6);
     arithmetic_checked(5);
     arithmetic_float(5.);
     cast();
@@ -236,15 +622,26 @@ fn main() {
     references(5);
     dereferences(&mut 5, &6, &S(7));
     slices();
+    let (direct, indirect) = duplicate_slice();
+    assert_eq!(direct, indirect);
+    repeat();
+    fn_pointers();
+    indirect_static();
 }
 
 #[inline(never)]
 fn opaque(_: impl Sized) {}
 
+#[inline(never)]
+fn identity<T>(x: T) -> T {
+    x
+}
+
 // EMIT_MIR gvn.subexpression_elimination.GVN.diff
 // EMIT_MIR gvn.wrap_unwrap.GVN.diff
 // EMIT_MIR gvn.repeated_index.GVN.diff
 // EMIT_MIR gvn.arithmetic.GVN.diff
+// EMIT_MIR gvn.comparison.GVN.diff
 // EMIT_MIR gvn.arithmetic_checked.GVN.diff
 // EMIT_MIR gvn.arithmetic_float.GVN.diff
 // EMIT_MIR gvn.cast.GVN.diff
@@ -252,3 +649,7 @@ fn opaque(_: impl Sized) {}
 // EMIT_MIR gvn.references.GVN.diff
 // EMIT_MIR gvn.dereferences.GVN.diff
 // EMIT_MIR gvn.slices.GVN.diff
+// EMIT_MIR gvn.duplicate_slice.GVN.diff
+// EMIT_MIR gvn.repeat.GVN.diff
+// EMIT_MIR gvn.fn_pointers.GVN.diff
+// EMIT_MIR gvn.indirect_static.GVN.diff
diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff
index de3d28d0575..ec449980312 100644
--- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff
@@ -85,32 +85,35 @@
   
       bb0: {
 -         StorageLive(_1);
++         nop;
           _1 = const "my favourite slice";
           StorageLive(_2);
--         StorageLive(_3);
--         _3 = _1;
+          StorageLive(_3);
+          _3 = _1;
 -         _2 = opaque::<&str>(move _3) -> [return: bb1, unwind unreachable];
 +         _2 = opaque::<&str>(_1) -> [return: bb1, unwind unreachable];
       }
   
       bb1: {
--         StorageDead(_3);
+          StorageDead(_3);
           StorageDead(_2);
           StorageLive(_4);
           _4 = _1;
           StorageLive(_5);
--         StorageLive(_6);
+          StorageLive(_6);
 -         _6 = _4;
 -         _5 = opaque::<&str>(move _6) -> [return: bb2, unwind unreachable];
++         _6 = _1;
 +         _5 = opaque::<&str>(_1) -> [return: bb2, unwind unreachable];
       }
   
       bb2: {
--         StorageDead(_6);
+          StorageDead(_6);
           StorageDead(_5);
--         StorageLive(_7);
+          StorageLive(_7);
           StorageLive(_8);
-          StorageLive(_9);
+-         StorageLive(_9);
++         nop;
           StorageLive(_10);
           StorageLive(_11);
           _11 = &(*_1);
@@ -120,28 +123,37 @@
       bb3: {
           StorageDead(_11);
           _9 = &_10;
-          StorageLive(_12);
+-         StorageLive(_12);
++         nop;
           StorageLive(_13);
           StorageLive(_14);
-          _14 = &(*_4);
+-         _14 = &(*_4);
++         _14 = &(*_1);
           _13 = core::str::<impl str>::as_ptr(move _14) -> [return: bb4, unwind unreachable];
       }
   
       bb4: {
           StorageDead(_14);
           _12 = &_13;
-          _8 = (move _9, move _12);
-          StorageDead(_12);
-          StorageDead(_9);
+-         _8 = (move _9, move _12);
+-         StorageDead(_12);
+-         StorageDead(_9);
++         _8 = (_9, _12);
++         nop;
++         nop;
           StorageLive(_15);
-          _15 = (_8.0: &*const u8);
+-         _15 = (_8.0: &*const u8);
++         _15 = _9;
           StorageLive(_16);
-          _16 = (_8.1: &*const u8);
+-         _16 = (_8.1: &*const u8);
++         _16 = _12;
           StorageLive(_17);
           StorageLive(_18);
-          _18 = (*_15);
+-         _18 = (*_15);
++         _18 = (*_9);
           StorageLive(_19);
-          _19 = (*_16);
+-         _19 = (*_16);
++         _19 = (*_12);
           _17 = Eq(move _18, move _19);
           switchInt(move _17) -> [0: bb6, otherwise: bb5];
       }
@@ -149,22 +161,23 @@
       bb5: {
           StorageDead(_19);
           StorageDead(_18);
--         _7 = const ();
+          _7 = const ();
           StorageDead(_17);
           StorageDead(_16);
           StorageDead(_15);
           StorageDead(_13);
           StorageDead(_10);
           StorageDead(_8);
--         StorageDead(_7);
+          StorageDead(_7);
 -         StorageLive(_29);
++         nop;
           StorageLive(_30);
           _30 = &(*_1);
           _29 = move _30 as &[u8] (Transmute);
           StorageDead(_30);
           StorageLive(_31);
--         StorageLive(_32);
--         _32 = _29;
+          StorageLive(_32);
+          _32 = _29;
 -         _31 = opaque::<&[u8]>(move _32) -> [return: bb7, unwind unreachable];
 +         _31 = opaque::<&[u8]>(_29) -> [return: bb7, unwind unreachable];
       }
@@ -173,30 +186,38 @@
           StorageDead(_19);
           StorageDead(_18);
 -         StorageLive(_21);
-          _21 = core::panicking::AssertKind::Eq;
+-         _21 = core::panicking::AssertKind::Eq;
++         nop;
++         _21 = const core::panicking::AssertKind::Eq;
           StorageLive(_22);
--         StorageLive(_23);
+          StorageLive(_23);
 -         _23 = move _21;
++         _23 = const core::panicking::AssertKind::Eq;
           StorageLive(_24);
-          StorageLive(_25);
-          _25 = &(*_15);
+-         StorageLive(_25);
+-         _25 = &(*_15);
++         nop;
++         _25 = &(*_9);
           _24 = &(*_25);
           StorageLive(_26);
-          StorageLive(_27);
-          _27 = &(*_16);
+-         StorageLive(_27);
+-         _27 = &(*_16);
++         nop;
++         _27 = &(*_12);
           _26 = &(*_27);
           StorageLive(_28);
           _28 = Option::<Arguments<'_>>::None;
--         _22 = core::panicking::assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind unreachable;
-+         _22 = core::panicking::assert_failed::<*const u8, *const u8>(_21, move _24, move _26, move _28) -> unwind unreachable;
+-         _22 = assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind unreachable;
++         _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, move _28) -> unwind unreachable;
       }
   
       bb7: {
--         StorageDead(_32);
+          StorageDead(_32);
           StorageDead(_31);
--         StorageLive(_33);
+          StorageLive(_33);
           StorageLive(_34);
-          StorageLive(_35);
+-         StorageLive(_35);
++         nop;
           StorageLive(_36);
           StorageLive(_37);
           _37 = &(*_1);
@@ -206,7 +227,8 @@
       bb8: {
           StorageDead(_37);
           _35 = &_36;
-          StorageLive(_38);
+-         StorageLive(_38);
++         nop;
           StorageLive(_39);
           StorageLive(_40);
           _40 = &(*_29);
@@ -216,18 +238,25 @@
       bb9: {
           StorageDead(_40);
           _38 = &_39;
-          _34 = (move _35, move _38);
-          StorageDead(_38);
-          StorageDead(_35);
+-         _34 = (move _35, move _38);
+-         StorageDead(_38);
+-         StorageDead(_35);
++         _34 = (_35, _38);
++         nop;
++         nop;
           StorageLive(_41);
-          _41 = (_34.0: &*const u8);
+-         _41 = (_34.0: &*const u8);
++         _41 = _35;
           StorageLive(_42);
-          _42 = (_34.1: &*const u8);
+-         _42 = (_34.1: &*const u8);
++         _42 = _38;
           StorageLive(_43);
           StorageLive(_44);
-          _44 = (*_41);
+-         _44 = (*_41);
++         _44 = (*_35);
           StorageLive(_45);
-          _45 = (*_42);
+-         _45 = (*_42);
++         _45 = (*_38);
           _43 = Eq(move _44, move _45);
           switchInt(move _43) -> [0: bb11, otherwise: bb10];
       }
@@ -235,18 +264,20 @@
       bb10: {
           StorageDead(_45);
           StorageDead(_44);
--         _33 = const ();
+          _33 = const ();
           StorageDead(_43);
           StorageDead(_42);
           StorageDead(_41);
           StorageDead(_39);
           StorageDead(_36);
           StorageDead(_34);
--         StorageDead(_33);
+          StorageDead(_33);
           _0 = const ();
 -         StorageDead(_29);
++         nop;
           StorageDead(_4);
 -         StorageDead(_1);
++         nop;
           return;
       }
   
@@ -254,22 +285,29 @@
           StorageDead(_45);
           StorageDead(_44);
 -         StorageLive(_47);
-          _47 = core::panicking::AssertKind::Eq;
+-         _47 = core::panicking::AssertKind::Eq;
++         nop;
++         _47 = const core::panicking::AssertKind::Eq;
           StorageLive(_48);
--         StorageLive(_49);
+          StorageLive(_49);
 -         _49 = move _47;
++         _49 = const core::panicking::AssertKind::Eq;
           StorageLive(_50);
-          StorageLive(_51);
-          _51 = &(*_41);
+-         StorageLive(_51);
+-         _51 = &(*_41);
++         nop;
++         _51 = &(*_35);
           _50 = &(*_51);
           StorageLive(_52);
-          StorageLive(_53);
-          _53 = &(*_42);
+-         StorageLive(_53);
+-         _53 = &(*_42);
++         nop;
++         _53 = &(*_38);
           _52 = &(*_53);
           StorageLive(_54);
           _54 = Option::<Arguments<'_>>::None;
--         _48 = core::panicking::assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind unreachable;
-+         _48 = core::panicking::assert_failed::<*const u8, *const u8>(_47, move _50, move _52, move _54) -> unwind unreachable;
+-         _48 = assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind unreachable;
++         _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, move _54) -> unwind unreachable;
       }
   }
   
diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff
index f22bb25436f..56a78ca8694 100644
--- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff
@@ -85,32 +85,35 @@
   
       bb0: {
 -         StorageLive(_1);
++         nop;
           _1 = const "my favourite slice";
           StorageLive(_2);
--         StorageLive(_3);
--         _3 = _1;
+          StorageLive(_3);
+          _3 = _1;
 -         _2 = opaque::<&str>(move _3) -> [return: bb1, unwind continue];
 +         _2 = opaque::<&str>(_1) -> [return: bb1, unwind continue];
       }
   
       bb1: {
--         StorageDead(_3);
+          StorageDead(_3);
           StorageDead(_2);
           StorageLive(_4);
           _4 = _1;
           StorageLive(_5);
--         StorageLive(_6);
+          StorageLive(_6);
 -         _6 = _4;
 -         _5 = opaque::<&str>(move _6) -> [return: bb2, unwind continue];
++         _6 = _1;
 +         _5 = opaque::<&str>(_1) -> [return: bb2, unwind continue];
       }
   
       bb2: {
--         StorageDead(_6);
+          StorageDead(_6);
           StorageDead(_5);
--         StorageLive(_7);
+          StorageLive(_7);
           StorageLive(_8);
-          StorageLive(_9);
+-         StorageLive(_9);
++         nop;
           StorageLive(_10);
           StorageLive(_11);
           _11 = &(*_1);
@@ -120,28 +123,37 @@
       bb3: {
           StorageDead(_11);
           _9 = &_10;
-          StorageLive(_12);
+-         StorageLive(_12);
++         nop;
           StorageLive(_13);
           StorageLive(_14);
-          _14 = &(*_4);
+-         _14 = &(*_4);
++         _14 = &(*_1);
           _13 = core::str::<impl str>::as_ptr(move _14) -> [return: bb4, unwind continue];
       }
   
       bb4: {
           StorageDead(_14);
           _12 = &_13;
-          _8 = (move _9, move _12);
-          StorageDead(_12);
-          StorageDead(_9);
+-         _8 = (move _9, move _12);
+-         StorageDead(_12);
+-         StorageDead(_9);
++         _8 = (_9, _12);
++         nop;
++         nop;
           StorageLive(_15);
-          _15 = (_8.0: &*const u8);
+-         _15 = (_8.0: &*const u8);
++         _15 = _9;
           StorageLive(_16);
-          _16 = (_8.1: &*const u8);
+-         _16 = (_8.1: &*const u8);
++         _16 = _12;
           StorageLive(_17);
           StorageLive(_18);
-          _18 = (*_15);
+-         _18 = (*_15);
++         _18 = (*_9);
           StorageLive(_19);
-          _19 = (*_16);
+-         _19 = (*_16);
++         _19 = (*_12);
           _17 = Eq(move _18, move _19);
           switchInt(move _17) -> [0: bb6, otherwise: bb5];
       }
@@ -149,22 +161,23 @@
       bb5: {
           StorageDead(_19);
           StorageDead(_18);
--         _7 = const ();
+          _7 = const ();
           StorageDead(_17);
           StorageDead(_16);
           StorageDead(_15);
           StorageDead(_13);
           StorageDead(_10);
           StorageDead(_8);
--         StorageDead(_7);
+          StorageDead(_7);
 -         StorageLive(_29);
++         nop;
           StorageLive(_30);
           _30 = &(*_1);
           _29 = move _30 as &[u8] (Transmute);
           StorageDead(_30);
           StorageLive(_31);
--         StorageLive(_32);
--         _32 = _29;
+          StorageLive(_32);
+          _32 = _29;
 -         _31 = opaque::<&[u8]>(move _32) -> [return: bb7, unwind continue];
 +         _31 = opaque::<&[u8]>(_29) -> [return: bb7, unwind continue];
       }
@@ -173,30 +186,38 @@
           StorageDead(_19);
           StorageDead(_18);
 -         StorageLive(_21);
-          _21 = core::panicking::AssertKind::Eq;
+-         _21 = core::panicking::AssertKind::Eq;
++         nop;
++         _21 = const core::panicking::AssertKind::Eq;
           StorageLive(_22);
--         StorageLive(_23);
+          StorageLive(_23);
 -         _23 = move _21;
++         _23 = const core::panicking::AssertKind::Eq;
           StorageLive(_24);
-          StorageLive(_25);
-          _25 = &(*_15);
+-         StorageLive(_25);
+-         _25 = &(*_15);
++         nop;
++         _25 = &(*_9);
           _24 = &(*_25);
           StorageLive(_26);
-          StorageLive(_27);
-          _27 = &(*_16);
+-         StorageLive(_27);
+-         _27 = &(*_16);
++         nop;
++         _27 = &(*_12);
           _26 = &(*_27);
           StorageLive(_28);
           _28 = Option::<Arguments<'_>>::None;
--         _22 = core::panicking::assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind continue;
-+         _22 = core::panicking::assert_failed::<*const u8, *const u8>(_21, move _24, move _26, move _28) -> unwind continue;
+-         _22 = assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind continue;
++         _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, move _28) -> unwind continue;
       }
   
       bb7: {
--         StorageDead(_32);
+          StorageDead(_32);
           StorageDead(_31);
--         StorageLive(_33);
+          StorageLive(_33);
           StorageLive(_34);
-          StorageLive(_35);
+-         StorageLive(_35);
++         nop;
           StorageLive(_36);
           StorageLive(_37);
           _37 = &(*_1);
@@ -206,7 +227,8 @@
       bb8: {
           StorageDead(_37);
           _35 = &_36;
-          StorageLive(_38);
+-         StorageLive(_38);
++         nop;
           StorageLive(_39);
           StorageLive(_40);
           _40 = &(*_29);
@@ -216,18 +238,25 @@
       bb9: {
           StorageDead(_40);
           _38 = &_39;
-          _34 = (move _35, move _38);
-          StorageDead(_38);
-          StorageDead(_35);
+-         _34 = (move _35, move _38);
+-         StorageDead(_38);
+-         StorageDead(_35);
++         _34 = (_35, _38);
++         nop;
++         nop;
           StorageLive(_41);
-          _41 = (_34.0: &*const u8);
+-         _41 = (_34.0: &*const u8);
++         _41 = _35;
           StorageLive(_42);
-          _42 = (_34.1: &*const u8);
+-         _42 = (_34.1: &*const u8);
++         _42 = _38;
           StorageLive(_43);
           StorageLive(_44);
-          _44 = (*_41);
+-         _44 = (*_41);
++         _44 = (*_35);
           StorageLive(_45);
-          _45 = (*_42);
+-         _45 = (*_42);
++         _45 = (*_38);
           _43 = Eq(move _44, move _45);
           switchInt(move _43) -> [0: bb11, otherwise: bb10];
       }
@@ -235,18 +264,20 @@
       bb10: {
           StorageDead(_45);
           StorageDead(_44);
--         _33 = const ();
+          _33 = const ();
           StorageDead(_43);
           StorageDead(_42);
           StorageDead(_41);
           StorageDead(_39);
           StorageDead(_36);
           StorageDead(_34);
--         StorageDead(_33);
+          StorageDead(_33);
           _0 = const ();
 -         StorageDead(_29);
++         nop;
           StorageDead(_4);
 -         StorageDead(_1);
++         nop;
           return;
       }
   
@@ -254,22 +285,29 @@
           StorageDead(_45);
           StorageDead(_44);
 -         StorageLive(_47);
-          _47 = core::panicking::AssertKind::Eq;
+-         _47 = core::panicking::AssertKind::Eq;
++         nop;
++         _47 = const core::panicking::AssertKind::Eq;
           StorageLive(_48);
--         StorageLive(_49);
+          StorageLive(_49);
 -         _49 = move _47;
++         _49 = const core::panicking::AssertKind::Eq;
           StorageLive(_50);
-          StorageLive(_51);
-          _51 = &(*_41);
+-         StorageLive(_51);
+-         _51 = &(*_41);
++         nop;
++         _51 = &(*_35);
           _50 = &(*_51);
           StorageLive(_52);
-          StorageLive(_53);
-          _53 = &(*_42);
+-         StorageLive(_53);
+-         _53 = &(*_42);
++         nop;
++         _53 = &(*_38);
           _52 = &(*_53);
           StorageLive(_54);
           _54 = Option::<Arguments<'_>>::None;
--         _48 = core::panicking::assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind continue;
-+         _48 = core::panicking::assert_failed::<*const u8, *const u8>(_47, move _50, move _52, move _54) -> unwind continue;
+-         _48 = assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind continue;
++         _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, move _54) -> unwind continue;
       }
   }
   
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 bf866e2f4d2..0a747d3aef0 100644
--- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff
@@ -65,11 +65,11 @@
       let mut _60: u64;
       let mut _61: u64;
       let mut _62: u64;
-      let mut _63: u64;
+      let _63: ();
       let mut _64: u64;
-      let _65: ();
+      let mut _65: u64;
       let mut _66: u64;
-      let mut _67: u64;
+      let _67: ();
       let mut _68: u64;
       let mut _69: u64;
       let mut _70: u64;
@@ -77,25 +77,25 @@
       let mut _72: u64;
       let mut _73: u64;
       let mut _74: u64;
-      let mut _75: u64;
-      let mut _76: u64;
-      let _77: ();
+      let mut _75: bool;
+      let _76: ();
+      let mut _77: u64;
       let mut _78: u64;
       let mut _79: u64;
-      let mut _80: u64;
-      let mut _81: u64;
-      let mut _82: bool;
+      let mut _80: bool;
+      let _81: ();
+      let mut _82: u64;
       let mut _83: u64;
-      let _84: ();
-      let mut _85: u64;
+      let mut _84: u64;
+      let _85: ();
       let mut _86: u64;
       let mut _87: u64;
       let mut _88: u64;
-      let mut _89: bool;
+      let _89: ();
       let mut _90: u64;
-      let _91: ();
+      let mut _91: u64;
       let mut _92: u64;
-      let mut _93: u64;
+      let _93: ();
       let mut _94: u64;
       let mut _95: u64;
       let mut _96: u64;
@@ -103,93 +103,91 @@
       let mut _98: u64;
       let mut _99: u64;
       let mut _100: u64;
-      let mut _101: u64;
-      let mut _102: u64;
-      let _103: ();
-      let mut _104: u64;
-      let mut _105: u64;
+      let _101: ();
+      let mut _102: u32;
+      let mut _103: u64;
+      let _104: ();
+      let mut _105: f32;
       let mut _106: u64;
-      let mut _107: u64;
-      let mut _108: u64;
-      let _109: ();
-      let mut _110: u64;
+      let _107: ();
+      let mut _108: S<u64>;
+      let mut _109: u64;
+      let _110: ();
       let mut _111: u64;
-      let mut _112: u64;
+      let mut _112: S<u64>;
       let mut _113: u64;
-      let mut _114: u64;
-      let _115: ();
+      let _114: ();
+      let mut _115: u64;
       let mut _116: u64;
       let mut _117: u64;
       let mut _118: u64;
       let mut _119: u64;
-      let mut _120: u64;
-      let _121: ();
-      let mut _122: S<u64>;
+      let _120: ();
+      let mut _121: u64;
+      let mut _122: u64;
       let mut _123: u64;
-      let _124: ();
+      let mut _124: u64;
       let mut _125: u64;
-      let mut _126: S<u64>;
-      let mut _127: u64;
-      let _128: &u64;
-      let _129: ();
+      let _126: &u64;
+      let _127: ();
+      let mut _128: u64;
+      let mut _129: u64;
       let mut _130: u64;
-      let mut _131: u64;
+      let _131: ();
       let mut _132: u64;
-      let _133: ();
+      let mut _133: u64;
       let mut _134: u64;
-      let mut _135: u64;
-      let mut _136: u64;
-      let _138: ();
+      let _136: ();
+      let mut _137: u64;
+      let mut _138: u64;
       let mut _139: u64;
-      let mut _140: u64;
+      let _140: ();
       let mut _141: u64;
-      let _142: ();
+      let mut _142: u64;
       let mut _143: u64;
-      let mut _144: u64;
-      let mut _145: u64;
+      let _144: ();
       let _146: ();
-      let _148: ();
+      let mut _147: u64;
+      let mut _148: u64;
       let mut _149: u64;
-      let mut _150: u64;
+      let _150: ();
       let mut _151: u64;
-      let _152: ();
+      let mut _152: u64;
       let mut _153: u64;
-      let mut _154: u64;
-      let mut _155: u64;
-      let _157: ();
+      let _155: ();
+      let mut _156: u64;
+      let mut _157: u64;
       let mut _158: u64;
-      let mut _159: u64;
+      let _159: ();
       let mut _160: u64;
-      let _161: ();
+      let mut _161: u64;
       let mut _162: u64;
-      let mut _163: u64;
-      let mut _164: u64;
-      let _166: ();
+      let _164: ();
+      let mut _165: u64;
+      let mut _166: u64;
       let mut _167: u64;
-      let mut _168: u64;
+      let _168: ();
       let mut _169: u64;
-      let _170: ();
+      let mut _170: u64;
       let mut _171: u64;
-      let mut _172: u64;
-      let mut _173: u64;
       scope 1 {
-          debug a => _128;
-          let _137: &mut u64;
+          debug a => _126;
+          let _135: &mut u64;
           scope 2 {
-              debug b => _137;
-              let _165: &u64;
+              debug b => _135;
+              let _163: &u64;
               scope 3 {
-                  let _147: *const u64;
+                  let _145: *const u64;
                   scope 4 {
-                      debug c => _147;
-                      let _156: *mut u64;
+                      debug c => _145;
+                      let _154: *mut u64;
                       scope 5 {
-                          debug d => _156;
+                          debug d => _154;
                       }
                   }
               }
               scope 6 {
-                  debug e => _165;
+                  debug e => _163;
               }
           }
       }
@@ -197,61 +195,68 @@
       bb0: {
           StorageLive(_4);
 -         StorageLive(_5);
--         StorageLive(_6);
--         _6 = _1;
--         StorageLive(_7);
--         _7 = _2;
++         nop;
+          StorageLive(_6);
+          _6 = _1;
+          StorageLive(_7);
+          _7 = _2;
 -         _5 = Add(move _6, move _7);
--         StorageDead(_7);
--         StorageDead(_6);
--         _4 = opaque::<u64>(move _5) -> [return: bb1, unwind unreachable];
 +         _5 = Add(_1, _2);
+          StorageDead(_7);
+          StorageDead(_6);
+-         _4 = opaque::<u64>(move _5) -> [return: bb1, unwind unreachable];
 +         _4 = opaque::<u64>(_5) -> [return: bb1, unwind unreachable];
       }
   
       bb1: {
 -         StorageDead(_5);
++         nop;
           StorageDead(_4);
           StorageLive(_8);
 -         StorageLive(_9);
--         StorageLive(_10);
--         _10 = _1;
--         StorageLive(_11);
--         _11 = _2;
++         nop;
+          StorageLive(_10);
+          _10 = _1;
+          StorageLive(_11);
+          _11 = _2;
 -         _9 = Mul(move _10, move _11);
--         StorageDead(_11);
--         StorageDead(_10);
--         _8 = opaque::<u64>(move _9) -> [return: bb2, unwind unreachable];
 +         _9 = Mul(_1, _2);
+          StorageDead(_11);
+          StorageDead(_10);
+-         _8 = opaque::<u64>(move _9) -> [return: bb2, unwind unreachable];
 +         _8 = opaque::<u64>(_9) -> [return: bb2, unwind unreachable];
       }
   
       bb2: {
 -         StorageDead(_9);
++         nop;
           StorageDead(_8);
           StorageLive(_12);
 -         StorageLive(_13);
--         StorageLive(_14);
--         _14 = _1;
--         StorageLive(_15);
--         _15 = _2;
++         nop;
+          StorageLive(_14);
+          _14 = _1;
+          StorageLive(_15);
+          _15 = _2;
 -         _13 = Sub(move _14, move _15);
--         StorageDead(_15);
--         StorageDead(_14);
--         _12 = opaque::<u64>(move _13) -> [return: bb3, unwind unreachable];
 +         _13 = Sub(_1, _2);
+          StorageDead(_15);
+          StorageDead(_14);
+-         _12 = opaque::<u64>(move _13) -> [return: bb3, unwind unreachable];
 +         _12 = opaque::<u64>(_13) -> [return: bb3, unwind unreachable];
       }
   
       bb3: {
 -         StorageDead(_13);
++         nop;
           StorageDead(_12);
           StorageLive(_16);
 -         StorageLive(_17);
--         StorageLive(_18);
--         _18 = _1;
--         StorageLive(_19);
--         _19 = _2;
++         nop;
+          StorageLive(_18);
+          _18 = _1;
+          StorageLive(_19);
+          _19 = _2;
 -         _20 = Eq(_19, const 0_u64);
 -         assert(!move _20, "attempt to divide `{}` by zero", _18) -> [success: bb4, unwind unreachable];
 +         _20 = Eq(_2, const 0_u64);
@@ -260,623 +265,701 @@
   
       bb4: {
 -         _17 = Div(move _18, move _19);
--         StorageDead(_19);
--         StorageDead(_18);
--         _16 = opaque::<u64>(move _17) -> [return: bb5, unwind unreachable];
 +         _17 = Div(_1, _2);
+          StorageDead(_19);
+          StorageDead(_18);
+-         _16 = opaque::<u64>(move _17) -> [return: bb5, unwind unreachable];
 +         _16 = opaque::<u64>(_17) -> [return: bb5, unwind unreachable];
       }
   
       bb5: {
 -         StorageDead(_17);
++         nop;
           StorageDead(_16);
           StorageLive(_21);
 -         StorageLive(_22);
--         StorageLive(_23);
--         _23 = _1;
--         StorageLive(_24);
--         _24 = _2;
++         nop;
+          StorageLive(_23);
+          _23 = _1;
+          StorageLive(_24);
+          _24 = _2;
 -         _25 = Eq(_24, const 0_u64);
 -         assert(!move _25, "attempt to calculate the remainder of `{}` with a divisor of zero", _23) -> [success: bb6, unwind unreachable];
++         _25 = _20;
 +         assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb6, unwind unreachable];
       }
   
       bb6: {
 -         _22 = Rem(move _23, move _24);
--         StorageDead(_24);
--         StorageDead(_23);
--         _21 = opaque::<u64>(move _22) -> [return: bb7, unwind unreachable];
 +         _22 = Rem(_1, _2);
+          StorageDead(_24);
+          StorageDead(_23);
+-         _21 = opaque::<u64>(move _22) -> [return: bb7, unwind unreachable];
 +         _21 = opaque::<u64>(_22) -> [return: bb7, unwind unreachable];
       }
   
       bb7: {
 -         StorageDead(_22);
++         nop;
           StorageDead(_21);
           StorageLive(_26);
 -         StorageLive(_27);
--         StorageLive(_28);
--         _28 = _1;
--         StorageLive(_29);
--         _29 = _2;
++         nop;
+          StorageLive(_28);
+          _28 = _1;
+          StorageLive(_29);
+          _29 = _2;
 -         _27 = BitAnd(move _28, move _29);
--         StorageDead(_29);
--         StorageDead(_28);
--         _26 = opaque::<u64>(move _27) -> [return: bb8, unwind unreachable];
 +         _27 = BitAnd(_1, _2);
+          StorageDead(_29);
+          StorageDead(_28);
+-         _26 = opaque::<u64>(move _27) -> [return: bb8, unwind unreachable];
 +         _26 = opaque::<u64>(_27) -> [return: bb8, unwind unreachable];
       }
   
       bb8: {
 -         StorageDead(_27);
++         nop;
           StorageDead(_26);
           StorageLive(_30);
 -         StorageLive(_31);
--         StorageLive(_32);
--         _32 = _1;
--         StorageLive(_33);
--         _33 = _2;
++         nop;
+          StorageLive(_32);
+          _32 = _1;
+          StorageLive(_33);
+          _33 = _2;
 -         _31 = BitOr(move _32, move _33);
--         StorageDead(_33);
--         StorageDead(_32);
--         _30 = opaque::<u64>(move _31) -> [return: bb9, unwind unreachable];
 +         _31 = BitOr(_1, _2);
+          StorageDead(_33);
+          StorageDead(_32);
+-         _30 = opaque::<u64>(move _31) -> [return: bb9, unwind unreachable];
 +         _30 = opaque::<u64>(_31) -> [return: bb9, unwind unreachable];
       }
   
       bb9: {
 -         StorageDead(_31);
++         nop;
           StorageDead(_30);
           StorageLive(_34);
 -         StorageLive(_35);
--         StorageLive(_36);
--         _36 = _1;
--         StorageLive(_37);
--         _37 = _2;
++         nop;
+          StorageLive(_36);
+          _36 = _1;
+          StorageLive(_37);
+          _37 = _2;
 -         _35 = BitXor(move _36, move _37);
--         StorageDead(_37);
--         StorageDead(_36);
--         _34 = opaque::<u64>(move _35) -> [return: bb10, unwind unreachable];
 +         _35 = BitXor(_1, _2);
+          StorageDead(_37);
+          StorageDead(_36);
+-         _34 = opaque::<u64>(move _35) -> [return: bb10, unwind unreachable];
 +         _34 = opaque::<u64>(_35) -> [return: bb10, unwind unreachable];
       }
   
       bb10: {
 -         StorageDead(_35);
++         nop;
           StorageDead(_34);
           StorageLive(_38);
 -         StorageLive(_39);
--         StorageLive(_40);
--         _40 = _1;
--         StorageLive(_41);
--         _41 = _2;
++         nop;
+          StorageLive(_40);
+          _40 = _1;
+          StorageLive(_41);
+          _41 = _2;
 -         _39 = Shl(move _40, move _41);
--         StorageDead(_41);
--         StorageDead(_40);
--         _38 = opaque::<u64>(move _39) -> [return: bb11, unwind unreachable];
 +         _39 = Shl(_1, _2);
+          StorageDead(_41);
+          StorageDead(_40);
+-         _38 = opaque::<u64>(move _39) -> [return: bb11, unwind unreachable];
 +         _38 = opaque::<u64>(_39) -> [return: bb11, unwind unreachable];
       }
   
       bb11: {
 -         StorageDead(_39);
++         nop;
           StorageDead(_38);
           StorageLive(_42);
 -         StorageLive(_43);
--         StorageLive(_44);
--         _44 = _1;
--         StorageLive(_45);
--         _45 = _2;
++         nop;
+          StorageLive(_44);
+          _44 = _1;
+          StorageLive(_45);
+          _45 = _2;
 -         _43 = Shr(move _44, move _45);
--         StorageDead(_45);
--         StorageDead(_44);
--         _42 = opaque::<u64>(move _43) -> [return: bb12, unwind unreachable];
 +         _43 = Shr(_1, _2);
+          StorageDead(_45);
+          StorageDead(_44);
+-         _42 = opaque::<u64>(move _43) -> [return: bb12, unwind unreachable];
 +         _42 = opaque::<u64>(_43) -> [return: bb12, unwind unreachable];
       }
   
       bb12: {
 -         StorageDead(_43);
++         nop;
           StorageDead(_42);
           StorageLive(_46);
-          StorageLive(_47);
--         StorageLive(_48);
--         _48 = _1;
+-         StorageLive(_47);
++         nop;
+          StorageLive(_48);
+          _48 = _1;
 -         _47 = move _48 as u32 (IntToInt);
--         StorageDead(_48);
 +         _47 = _1 as u32 (IntToInt);
-          _46 = opaque::<u32>(move _47) -> [return: bb13, unwind unreachable];
+          StorageDead(_48);
+-         _46 = opaque::<u32>(move _47) -> [return: bb13, unwind unreachable];
++         _46 = opaque::<u32>(_47) -> [return: bb13, unwind unreachable];
       }
   
       bb13: {
-          StorageDead(_47);
+-         StorageDead(_47);
++         nop;
           StorageDead(_46);
           StorageLive(_49);
-          StorageLive(_50);
--         StorageLive(_51);
--         _51 = _1;
+-         StorageLive(_50);
++         nop;
+          StorageLive(_51);
+          _51 = _1;
 -         _50 = move _51 as f32 (IntToFloat);
--         StorageDead(_51);
 +         _50 = _1 as f32 (IntToFloat);
-          _49 = opaque::<f32>(move _50) -> [return: bb14, unwind unreachable];
+          StorageDead(_51);
+-         _49 = opaque::<f32>(move _50) -> [return: bb14, unwind unreachable];
++         _49 = opaque::<f32>(_50) -> [return: bb14, unwind unreachable];
       }
   
       bb14: {
-          StorageDead(_50);
+-         StorageDead(_50);
++         nop;
           StorageDead(_49);
           StorageLive(_52);
 -         StorageLive(_53);
--         StorageLive(_54);
--         _54 = _1;
++         nop;
+          StorageLive(_54);
+          _54 = _1;
 -         _53 = S::<u64>(move _54);
--         StorageDead(_54);
--         _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind unreachable];
 +         _53 = S::<u64>(_1);
+          StorageDead(_54);
+-         _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind unreachable];
 +         _52 = opaque::<S<u64>>(_53) -> [return: bb15, unwind unreachable];
       }
   
       bb15: {
 -         StorageDead(_53);
++         nop;
           StorageDead(_52);
           StorageLive(_55);
--         StorageLive(_56);
--         StorageLive(_57);
--         StorageLive(_58);
--         _58 = _1;
+          StorageLive(_56);
+          StorageLive(_57);
+          StorageLive(_58);
+          _58 = _1;
 -         _57 = S::<u64>(move _58);
--         StorageDead(_58);
++         _57 = _53;
+          StorageDead(_58);
 -         _56 = (_57.0: u64);
 -         _55 = opaque::<u64>(move _56) -> [return: bb16, unwind unreachable];
-+         _56 = (_53.0: u64);
-+         _55 = opaque::<u64>(_56) -> [return: bb16, unwind unreachable];
++         _56 = _1;
++         _55 = opaque::<u64>(_1) -> [return: bb16, unwind unreachable];
       }
   
       bb16: {
--         StorageDead(_56);
--         StorageDead(_57);
+          StorageDead(_56);
+          StorageDead(_57);
           StorageDead(_55);
           StorageLive(_59);
           StorageLive(_60);
--         StorageLive(_61);
--         StorageLive(_62);
--         _62 = _1;
--         StorageLive(_63);
--         _63 = _2;
--         _61 = Add(move _62, move _63);
--         StorageDead(_63);
--         StorageDead(_62);
-          StorageLive(_64);
-          _64 = _3;
--         _60 = Add(move _61, move _64);
-+         _60 = Add(_5, move _64);
-          StorageDead(_64);
--         StorageDead(_61);
-          _59 = opaque::<u64>(move _60) -> [return: bb17, unwind unreachable];
+          StorageLive(_61);
+          _61 = _1;
+          StorageLive(_62);
+          _62 = _2;
+-         _60 = Add(move _61, move _62);
++         _60 = _5;
+          StorageDead(_62);
+          StorageDead(_61);
+-         _59 = opaque::<u64>(move _60) -> [return: bb17, unwind unreachable];
++         _59 = opaque::<u64>(_5) -> [return: bb17, unwind unreachable];
       }
   
       bb17: {
           StorageDead(_60);
           StorageDead(_59);
+          StorageLive(_63);
+          StorageLive(_64);
           StorageLive(_65);
+          _65 = _1;
           StorageLive(_66);
--         StorageLive(_67);
--         StorageLive(_68);
--         _68 = _1;
--         StorageLive(_69);
--         _69 = _2;
--         _67 = Mul(move _68, move _69);
--         StorageDead(_69);
--         StorageDead(_68);
+          _66 = _2;
+-         _64 = Mul(move _65, move _66);
++         _64 = _9;
+          StorageDead(_66);
+          StorageDead(_65);
+-         _63 = opaque::<u64>(move _64) -> [return: bb18, unwind unreachable];
++         _63 = opaque::<u64>(_9) -> [return: bb18, unwind unreachable];
+      }
+  
+      bb18: {
+          StorageDead(_64);
+          StorageDead(_63);
+          StorageLive(_67);
+          StorageLive(_68);
+          StorageLive(_69);
+          _69 = _1;
           StorageLive(_70);
-          _70 = _3;
--         _66 = Add(move _67, move _70);
-+         _66 = Add(_9, move _70);
+          _70 = _2;
+-         _68 = Sub(move _69, move _70);
++         _68 = _13;
           StorageDead(_70);
--         StorageDead(_67);
-          _65 = opaque::<u64>(move _66) -> [return: bb18, unwind unreachable];
+          StorageDead(_69);
+-         _67 = opaque::<u64>(move _68) -> [return: bb19, unwind unreachable];
++         _67 = opaque::<u64>(_13) -> [return: bb19, unwind unreachable];
       }
   
-      bb18: {
-          StorageDead(_66);
-          StorageDead(_65);
+      bb19: {
+          StorageDead(_68);
+          StorageDead(_67);
           StorageLive(_71);
           StorageLive(_72);
--         StorageLive(_73);
--         StorageLive(_74);
--         _74 = _1;
--         StorageLive(_75);
--         _75 = _2;
--         _73 = Sub(move _74, move _75);
--         StorageDead(_75);
--         StorageDead(_74);
-          StorageLive(_76);
-          _76 = _3;
--         _72 = Add(move _73, move _76);
-+         _72 = Add(_13, move _76);
-          StorageDead(_76);
--         StorageDead(_73);
-          _71 = opaque::<u64>(move _72) -> [return: bb19, unwind unreachable];
+          StorageLive(_73);
+          _73 = _1;
+          StorageLive(_74);
+          _74 = _2;
+-         _75 = Eq(_74, const 0_u64);
+-         assert(!move _75, "attempt to divide `{}` by zero", _73) -> [success: bb20, unwind unreachable];
++         _75 = _20;
++         assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind unreachable];
       }
   
-      bb19: {
+      bb20: {
+-         _72 = Div(move _73, move _74);
++         _72 = _17;
+          StorageDead(_74);
+          StorageDead(_73);
+-         _71 = opaque::<u64>(move _72) -> [return: bb21, unwind unreachable];
++         _71 = opaque::<u64>(_17) -> [return: bb21, unwind unreachable];
+      }
+  
+      bb21: {
           StorageDead(_72);
           StorageDead(_71);
+          StorageLive(_76);
           StorageLive(_77);
           StorageLive(_78);
--         StorageLive(_79);
--         StorageLive(_80);
--         _80 = _1;
--         StorageLive(_81);
--         _81 = _2;
--         _82 = Eq(_81, const 0_u64);
--         assert(!move _82, "attempt to divide `{}` by zero", _80) -> [success: bb20, unwind unreachable];
-+         assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind unreachable];
+          _78 = _1;
+          StorageLive(_79);
+          _79 = _2;
+-         _80 = Eq(_79, const 0_u64);
+-         assert(!move _80, "attempt to calculate the remainder of `{}` with a divisor of zero", _78) -> [success: bb22, unwind unreachable];
++         _80 = _20;
++         assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind unreachable];
       }
   
-      bb20: {
--         _79 = Div(move _80, move _81);
--         StorageDead(_81);
--         StorageDead(_80);
-          StorageLive(_83);
-          _83 = _3;
--         _78 = Add(move _79, move _83);
-+         _78 = Add(_17, move _83);
-          StorageDead(_83);
--         StorageDead(_79);
-          _77 = opaque::<u64>(move _78) -> [return: bb21, unwind unreachable];
+      bb22: {
+-         _77 = Rem(move _78, move _79);
++         _77 = _22;
+          StorageDead(_79);
+          StorageDead(_78);
+-         _76 = opaque::<u64>(move _77) -> [return: bb23, unwind unreachable];
++         _76 = opaque::<u64>(_22) -> [return: bb23, unwind unreachable];
       }
   
-      bb21: {
-          StorageDead(_78);
+      bb23: {
           StorageDead(_77);
+          StorageDead(_76);
+          StorageLive(_81);
+          StorageLive(_82);
+          StorageLive(_83);
+          _83 = _1;
           StorageLive(_84);
-          StorageLive(_85);
--         StorageLive(_86);
--         StorageLive(_87);
--         _87 = _1;
--         StorageLive(_88);
--         _88 = _2;
--         _89 = Eq(_88, const 0_u64);
--         assert(!move _89, "attempt to calculate the remainder of `{}` with a divisor of zero", _87) -> [success: bb22, unwind unreachable];
-+         assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind unreachable];
+          _84 = _2;
+-         _82 = BitAnd(move _83, move _84);
++         _82 = _27;
+          StorageDead(_84);
+          StorageDead(_83);
+-         _81 = opaque::<u64>(move _82) -> [return: bb24, unwind unreachable];
++         _81 = opaque::<u64>(_27) -> [return: bb24, unwind unreachable];
       }
   
-      bb22: {
--         _86 = Rem(move _87, move _88);
--         StorageDead(_88);
--         StorageDead(_87);
-          StorageLive(_90);
-          _90 = _3;
--         _85 = Add(move _86, move _90);
-+         _85 = Add(_22, move _90);
-          StorageDead(_90);
--         StorageDead(_86);
-          _84 = opaque::<u64>(move _85) -> [return: bb23, unwind unreachable];
+      bb24: {
+          StorageDead(_82);
+          StorageDead(_81);
+          StorageLive(_85);
+          StorageLive(_86);
+          StorageLive(_87);
+          _87 = _1;
+          StorageLive(_88);
+          _88 = _2;
+-         _86 = BitOr(move _87, move _88);
++         _86 = _31;
+          StorageDead(_88);
+          StorageDead(_87);
+-         _85 = opaque::<u64>(move _86) -> [return: bb25, unwind unreachable];
++         _85 = opaque::<u64>(_31) -> [return: bb25, unwind unreachable];
       }
   
-      bb23: {
+      bb25: {
+          StorageDead(_86);
           StorageDead(_85);
-          StorageDead(_84);
+          StorageLive(_89);
+          StorageLive(_90);
           StorageLive(_91);
+          _91 = _1;
           StorageLive(_92);
--         StorageLive(_93);
--         StorageLive(_94);
--         _94 = _1;
--         StorageLive(_95);
--         _95 = _2;
--         _93 = BitAnd(move _94, move _95);
--         StorageDead(_95);
--         StorageDead(_94);
+          _92 = _2;
+-         _90 = BitXor(move _91, move _92);
++         _90 = _35;
+          StorageDead(_92);
+          StorageDead(_91);
+-         _89 = opaque::<u64>(move _90) -> [return: bb26, unwind unreachable];
++         _89 = opaque::<u64>(_35) -> [return: bb26, unwind unreachable];
+      }
+  
+      bb26: {
+          StorageDead(_90);
+          StorageDead(_89);
+          StorageLive(_93);
+          StorageLive(_94);
+          StorageLive(_95);
+          _95 = _1;
           StorageLive(_96);
-          _96 = _3;
--         _92 = Add(move _93, move _96);
-+         _92 = Add(_27, move _96);
+          _96 = _2;
+-         _94 = Shl(move _95, move _96);
++         _94 = _39;
           StorageDead(_96);
--         StorageDead(_93);
-          _91 = opaque::<u64>(move _92) -> [return: bb24, unwind unreachable];
+          StorageDead(_95);
+-         _93 = opaque::<u64>(move _94) -> [return: bb27, unwind unreachable];
++         _93 = opaque::<u64>(_39) -> [return: bb27, unwind unreachable];
       }
   
-      bb24: {
-          StorageDead(_92);
-          StorageDead(_91);
+      bb27: {
+          StorageDead(_94);
+          StorageDead(_93);
           StorageLive(_97);
           StorageLive(_98);
--         StorageLive(_99);
--         StorageLive(_100);
--         _100 = _1;
--         StorageLive(_101);
--         _101 = _2;
--         _99 = BitOr(move _100, move _101);
--         StorageDead(_101);
--         StorageDead(_100);
-          StorageLive(_102);
-          _102 = _3;
--         _98 = Add(move _99, move _102);
-+         _98 = Add(_31, move _102);
-          StorageDead(_102);
--         StorageDead(_99);
-          _97 = opaque::<u64>(move _98) -> [return: bb25, unwind unreachable];
+          StorageLive(_99);
+          _99 = _1;
+          StorageLive(_100);
+          _100 = _2;
+-         _98 = Shr(move _99, move _100);
++         _98 = _43;
+          StorageDead(_100);
+          StorageDead(_99);
+-         _97 = opaque::<u64>(move _98) -> [return: bb28, unwind unreachable];
++         _97 = opaque::<u64>(_43) -> [return: bb28, unwind unreachable];
       }
   
-      bb25: {
+      bb28: {
           StorageDead(_98);
           StorageDead(_97);
+          StorageLive(_101);
+          StorageLive(_102);
           StorageLive(_103);
+          _103 = _1;
+-         _102 = move _103 as u32 (IntToInt);
++         _102 = _47;
+          StorageDead(_103);
+-         _101 = opaque::<u32>(move _102) -> [return: bb29, unwind unreachable];
++         _101 = opaque::<u32>(_47) -> [return: bb29, unwind unreachable];
+      }
+  
+      bb29: {
+          StorageDead(_102);
+          StorageDead(_101);
           StorageLive(_104);
--         StorageLive(_105);
--         StorageLive(_106);
--         _106 = _1;
--         StorageLive(_107);
--         _107 = _2;
--         _105 = BitXor(move _106, move _107);
--         StorageDead(_107);
--         StorageDead(_106);
-          StorageLive(_108);
-          _108 = _3;
--         _104 = Add(move _105, move _108);
-+         _104 = Add(_35, move _108);
-          StorageDead(_108);
--         StorageDead(_105);
-          _103 = opaque::<u64>(move _104) -> [return: bb26, unwind unreachable];
+          StorageLive(_105);
+          StorageLive(_106);
+          _106 = _1;
+-         _105 = move _106 as f32 (IntToFloat);
++         _105 = _50;
+          StorageDead(_106);
+-         _104 = opaque::<f32>(move _105) -> [return: bb30, unwind unreachable];
++         _104 = opaque::<f32>(_50) -> [return: bb30, unwind unreachable];
       }
   
-      bb26: {
+      bb30: {
+          StorageDead(_105);
           StorageDead(_104);
-          StorageDead(_103);
+          StorageLive(_107);
+          StorageLive(_108);
           StorageLive(_109);
+          _109 = _1;
+-         _108 = S::<u64>(move _109);
++         _108 = _53;
+          StorageDead(_109);
+-         _107 = opaque::<S<u64>>(move _108) -> [return: bb31, unwind unreachable];
++         _107 = opaque::<S<u64>>(_53) -> [return: bb31, unwind unreachable];
+      }
+  
+      bb31: {
+          StorageDead(_108);
+          StorageDead(_107);
           StorageLive(_110);
--         StorageLive(_111);
--         StorageLive(_112);
--         _112 = _1;
--         StorageLive(_113);
--         _113 = _2;
--         _111 = Shl(move _112, move _113);
--         StorageDead(_113);
--         StorageDead(_112);
-          StorageLive(_114);
-          _114 = _3;
--         _110 = Add(move _111, move _114);
-+         _110 = Add(_39, move _114);
-          StorageDead(_114);
--         StorageDead(_111);
-          _109 = opaque::<u64>(move _110) -> [return: bb27, unwind unreachable];
+          StorageLive(_111);
+          StorageLive(_112);
+          StorageLive(_113);
+          _113 = _1;
+-         _112 = S::<u64>(move _113);
++         _112 = _53;
+          StorageDead(_113);
+-         _111 = (_112.0: u64);
+-         _110 = opaque::<u64>(move _111) -> [return: bb32, unwind unreachable];
++         _111 = _1;
++         _110 = opaque::<u64>(_1) -> [return: bb32, unwind unreachable];
       }
   
-      bb27: {
+      bb32: {
+          StorageDead(_111);
+          StorageDead(_112);
           StorageDead(_110);
-          StorageDead(_109);
-          StorageLive(_115);
+          StorageLive(_114);
+-         StorageLive(_115);
++         nop;
           StorageLive(_116);
--         StorageLive(_117);
--         StorageLive(_118);
--         _118 = _1;
--         StorageLive(_119);
--         _119 = _2;
--         _117 = Shr(move _118, move _119);
--         StorageDead(_119);
--         StorageDead(_118);
-          StorageLive(_120);
-          _120 = _3;
--         _116 = Add(move _117, move _120);
-+         _116 = Add(_43, move _120);
-          StorageDead(_120);
--         StorageDead(_117);
-          _115 = opaque::<u64>(move _116) -> [return: bb28, unwind unreachable];
+          StorageLive(_117);
+          _117 = _1;
+          StorageLive(_118);
+          _118 = _2;
+-         _116 = Mul(move _117, move _118);
++         _116 = _9;
+          StorageDead(_118);
+          StorageDead(_117);
+          StorageLive(_119);
+          _119 = _2;
+-         _115 = Sub(move _116, move _119);
++         _115 = Sub(_9, _2);
+          StorageDead(_119);
+          StorageDead(_116);
+-         _114 = opaque::<u64>(move _115) -> [return: bb33, unwind unreachable];
++         _114 = opaque::<u64>(_115) -> [return: bb33, unwind unreachable];
       }
   
-      bb28: {
-          StorageDead(_116);
-          StorageDead(_115);
+      bb33: {
+-         StorageDead(_115);
++         nop;
+          StorageDead(_114);
+          StorageLive(_120);
           StorageLive(_121);
--         StorageLive(_122);
--         StorageLive(_123);
--         _123 = _1;
--         _122 = S::<u64>(move _123);
--         StorageDead(_123);
--         _121 = opaque::<S<u64>>(move _122) -> [return: bb29, unwind unreachable];
-+         _121 = opaque::<S<u64>>(_53) -> [return: bb29, unwind unreachable];
+          StorageLive(_122);
+          StorageLive(_123);
+          _123 = _1;
+          StorageLive(_124);
+          _124 = _2;
+-         _122 = Mul(move _123, move _124);
++         _122 = _9;
+          StorageDead(_124);
+          StorageDead(_123);
+          StorageLive(_125);
+          _125 = _2;
+-         _121 = Sub(move _122, move _125);
++         _121 = _115;
+          StorageDead(_125);
+          StorageDead(_122);
+-         _120 = opaque::<u64>(move _121) -> [return: bb34, unwind unreachable];
++         _120 = opaque::<u64>(_115) -> [return: bb34, unwind unreachable];
       }
   
-      bb29: {
--         StorageDead(_122);
+      bb34: {
           StorageDead(_121);
-          StorageLive(_124);
--         StorageLive(_125);
+          StorageDead(_120);
 -         StorageLive(_126);
--         StorageLive(_127);
--         _127 = _1;
--         _126 = S::<u64>(move _127);
--         StorageDead(_127);
--         _125 = (_126.0: u64);
--         _124 = opaque::<u64>(move _125) -> [return: bb30, unwind unreachable];
-+         _124 = opaque::<u64>(_56) -> [return: bb30, unwind unreachable];
-      }
-  
-      bb30: {
--         StorageDead(_125);
--         StorageDead(_126);
-          StorageDead(_124);
-          StorageLive(_128);
-          _128 = &_3;
-          StorageLive(_129);
--         StorageLive(_130);
--         StorageLive(_131);
-          _131 = (*_128);
--         StorageLive(_132);
--         _132 = _1;
--         _130 = Add(move _131, move _132);
--         StorageDead(_132);
--         StorageDead(_131);
--         _129 = opaque::<u64>(move _130) -> [return: bb31, unwind unreachable];
-+         _130 = Add(_131, _1);
-+         _129 = opaque::<u64>(_130) -> [return: bb31, unwind unreachable];
++         nop;
+          _126 = &_3;
+          StorageLive(_127);
+-         StorageLive(_128);
+-         StorageLive(_129);
++         nop;
++         nop;
+          _129 = (*_126);
+          StorageLive(_130);
+          _130 = _1;
+-         _128 = Add(move _129, move _130);
++         _128 = Add(_129, _1);
+          StorageDead(_130);
+-         StorageDead(_129);
+-         _127 = opaque::<u64>(move _128) -> [return: bb35, unwind unreachable];
++         nop;
++         _127 = opaque::<u64>(_128) -> [return: bb35, unwind unreachable];
       }
   
-      bb31: {
--         StorageDead(_130);
-          StorageDead(_129);
+      bb35: {
+-         StorageDead(_128);
++         nop;
+          StorageDead(_127);
+          StorageLive(_131);
+          StorageLive(_132);
           StorageLive(_133);
--         StorageLive(_134);
--         StorageLive(_135);
--         _135 = (*_128);
--         StorageLive(_136);
--         _136 = _1;
--         _134 = Add(move _135, move _136);
--         StorageDead(_136);
--         StorageDead(_135);
--         _133 = opaque::<u64>(move _134) -> [return: bb32, unwind unreachable];
-+         _133 = opaque::<u64>(_130) -> [return: bb32, unwind unreachable];
+-         _133 = (*_126);
++         _133 = _129;
+          StorageLive(_134);
+          _134 = _1;
+-         _132 = Add(move _133, move _134);
++         _132 = _128;
+          StorageDead(_134);
+          StorageDead(_133);
+-         _131 = opaque::<u64>(move _132) -> [return: bb36, unwind unreachable];
++         _131 = opaque::<u64>(_128) -> [return: bb36, unwind unreachable];
       }
   
-      bb32: {
--         StorageDead(_134);
-          StorageDead(_133);
+      bb36: {
+          StorageDead(_132);
+          StorageDead(_131);
+-         StorageLive(_135);
++         nop;
+          _135 = &mut _3;
+          StorageLive(_136);
           StorageLive(_137);
-          _137 = &mut _3;
           StorageLive(_138);
+          _138 = (*_135);
           StorageLive(_139);
-          StorageLive(_140);
-          _140 = (*_137);
--         StorageLive(_141);
--         _141 = _1;
--         _139 = Add(move _140, move _141);
--         StorageDead(_141);
-+         _139 = Add(move _140, _1);
-          StorageDead(_140);
-          _138 = opaque::<u64>(move _139) -> [return: bb33, unwind unreachable];
-      }
-  
-      bb33: {
+          _139 = _1;
+-         _137 = Add(move _138, move _139);
++         _137 = Add(move _138, _1);
           StorageDead(_139);
           StorageDead(_138);
-          StorageLive(_142);
-          StorageLive(_143);
-          StorageLive(_144);
-          _144 = (*_137);
--         StorageLive(_145);
--         _145 = _1;
--         _143 = Add(move _144, move _145);
--         StorageDead(_145);
-+         _143 = Add(move _144, _1);
-          StorageDead(_144);
-          _142 = opaque::<u64>(move _143) -> [return: bb34, unwind unreachable];
+          _136 = opaque::<u64>(move _137) -> [return: bb37, unwind unreachable];
       }
   
-      bb34: {
+      bb37: {
+          StorageDead(_137);
+          StorageDead(_136);
+          StorageLive(_140);
+          StorageLive(_141);
+          StorageLive(_142);
+          _142 = (*_135);
+          StorageLive(_143);
+          _143 = _1;
+-         _141 = Add(move _142, move _143);
++         _141 = Add(move _142, _1);
           StorageDead(_143);
           StorageDead(_142);
--         StorageLive(_146);
+          _140 = opaque::<u64>(move _141) -> [return: bb38, unwind unreachable];
+      }
+  
+      bb38: {
+          StorageDead(_141);
+          StorageDead(_140);
+          StorageLive(_144);
+-         StorageLive(_145);
++         nop;
+          _145 = &raw const _3;
+          StorageLive(_146);
           StorageLive(_147);
-          _147 = &raw const _3;
           StorageLive(_148);
+          _148 = (*_145);
           StorageLive(_149);
-          StorageLive(_150);
-          _150 = (*_147);
--         StorageLive(_151);
--         _151 = _1;
--         _149 = Add(move _150, move _151);
--         StorageDead(_151);
-+         _149 = Add(move _150, _1);
-          StorageDead(_150);
-          _148 = opaque::<u64>(move _149) -> [return: bb35, unwind unreachable];
-      }
-  
-      bb35: {
+          _149 = _1;
+-         _147 = Add(move _148, move _149);
++         _147 = Add(move _148, _1);
           StorageDead(_149);
           StorageDead(_148);
-          StorageLive(_152);
-          StorageLive(_153);
-          StorageLive(_154);
-          _154 = (*_147);
--         StorageLive(_155);
--         _155 = _1;
--         _153 = Add(move _154, move _155);
--         StorageDead(_155);
-+         _153 = Add(move _154, _1);
-          StorageDead(_154);
-          _152 = opaque::<u64>(move _153) -> [return: bb36, unwind unreachable];
+          _146 = opaque::<u64>(move _147) -> [return: bb39, unwind unreachable];
       }
   
-      bb36: {
+      bb39: {
+          StorageDead(_147);
+          StorageDead(_146);
+          StorageLive(_150);
+          StorageLive(_151);
+          StorageLive(_152);
+          _152 = (*_145);
+          StorageLive(_153);
+          _153 = _1;
+-         _151 = Add(move _152, move _153);
++         _151 = Add(move _152, _1);
           StorageDead(_153);
           StorageDead(_152);
+          _150 = opaque::<u64>(move _151) -> [return: bb40, unwind unreachable];
+      }
+  
+      bb40: {
+          StorageDead(_151);
+          StorageDead(_150);
+-         StorageLive(_154);
++         nop;
+          _154 = &raw mut _3;
+          StorageLive(_155);
           StorageLive(_156);
-          _156 = &raw mut _3;
           StorageLive(_157);
+          _157 = (*_154);
           StorageLive(_158);
-          StorageLive(_159);
-          _159 = (*_156);
--         StorageLive(_160);
--         _160 = _1;
--         _158 = Add(move _159, move _160);
--         StorageDead(_160);
-+         _158 = Add(move _159, _1);
-          StorageDead(_159);
-          _157 = opaque::<u64>(move _158) -> [return: bb37, unwind unreachable];
-      }
-  
-      bb37: {
+          _158 = _1;
+-         _156 = Add(move _157, move _158);
++         _156 = Add(move _157, _1);
           StorageDead(_158);
           StorageDead(_157);
-          StorageLive(_161);
-          StorageLive(_162);
-          StorageLive(_163);
-          _163 = (*_156);
--         StorageLive(_164);
--         _164 = _1;
--         _162 = Add(move _163, move _164);
--         StorageDead(_164);
-+         _162 = Add(move _163, _1);
-          StorageDead(_163);
-          _161 = opaque::<u64>(move _162) -> [return: bb38, unwind unreachable];
+          _155 = opaque::<u64>(move _156) -> [return: bb41, unwind unreachable];
       }
   
-      bb38: {
+      bb41: {
+          StorageDead(_156);
+          StorageDead(_155);
+          StorageLive(_159);
+          StorageLive(_160);
+          StorageLive(_161);
+          _161 = (*_154);
+          StorageLive(_162);
+          _162 = _1;
+-         _160 = Add(move _161, move _162);
++         _160 = Add(move _161, _1);
           StorageDead(_162);
           StorageDead(_161);
--         _146 = const ();
-          StorageDead(_156);
-          StorageDead(_147);
--         StorageDead(_146);
-          StorageLive(_165);
-          _165 = &_3;
-          StorageLive(_166);
--         StorageLive(_167);
--         StorageLive(_168);
-          _168 = (*_165);
--         StorageLive(_169);
--         _169 = _1;
--         _167 = Add(move _168, move _169);
--         StorageDead(_169);
--         StorageDead(_168);
--         _166 = opaque::<u64>(move _167) -> [return: bb39, unwind unreachable];
-+         _167 = Add(_168, _1);
-+         _166 = opaque::<u64>(_167) -> [return: bb39, unwind unreachable];
+          _159 = opaque::<u64>(move _160) -> [return: bb42, unwind unreachable];
       }
   
-      bb39: {
--         StorageDead(_167);
-          StorageDead(_166);
+      bb42: {
+          StorageDead(_160);
+          StorageDead(_159);
+          _144 = const ();
+-         StorageDead(_154);
+-         StorageDead(_145);
++         nop;
++         nop;
+          StorageDead(_144);
+-         StorageLive(_163);
++         nop;
+          _163 = &_3;
+          StorageLive(_164);
+-         StorageLive(_165);
+-         StorageLive(_166);
++         nop;
++         nop;
+          _166 = (*_163);
+          StorageLive(_167);
+          _167 = _1;
+-         _165 = Add(move _166, move _167);
++         _165 = Add(_166, _1);
+          StorageDead(_167);
+-         StorageDead(_166);
+-         _164 = opaque::<u64>(move _165) -> [return: bb43, unwind unreachable];
++         nop;
++         _164 = opaque::<u64>(_165) -> [return: bb43, unwind unreachable];
+      }
+  
+      bb43: {
+-         StorageDead(_165);
++         nop;
+          StorageDead(_164);
+          StorageLive(_168);
+          StorageLive(_169);
           StorageLive(_170);
--         StorageLive(_171);
--         StorageLive(_172);
--         _172 = (*_165);
--         StorageLive(_173);
--         _173 = _1;
--         _171 = Add(move _172, move _173);
--         StorageDead(_173);
--         StorageDead(_172);
--         _170 = opaque::<u64>(move _171) -> [return: bb40, unwind unreachable];
-+         _170 = opaque::<u64>(_167) -> [return: bb40, unwind unreachable];
+-         _170 = (*_163);
++         _170 = _166;
+          StorageLive(_171);
+          _171 = _1;
+-         _169 = Add(move _170, move _171);
++         _169 = _165;
+          StorageDead(_171);
+          StorageDead(_170);
+-         _168 = opaque::<u64>(move _169) -> [return: bb44, unwind unreachable];
++         _168 = opaque::<u64>(_165) -> [return: bb44, unwind unreachable];
       }
   
-      bb40: {
--         StorageDead(_171);
-          StorageDead(_170);
+      bb44: {
+          StorageDead(_169);
+          StorageDead(_168);
           _0 = const ();
-          StorageDead(_165);
-          StorageDead(_137);
-          StorageDead(_128);
+-         StorageDead(_163);
+-         StorageDead(_135);
+-         StorageDead(_126);
++         nop;
++         nop;
++         nop;
           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 68b05290719..119a4d9bbe9 100644
--- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff
@@ -65,11 +65,11 @@
       let mut _60: u64;
       let mut _61: u64;
       let mut _62: u64;
-      let mut _63: u64;
+      let _63: ();
       let mut _64: u64;
-      let _65: ();
+      let mut _65: u64;
       let mut _66: u64;
-      let mut _67: u64;
+      let _67: ();
       let mut _68: u64;
       let mut _69: u64;
       let mut _70: u64;
@@ -77,25 +77,25 @@
       let mut _72: u64;
       let mut _73: u64;
       let mut _74: u64;
-      let mut _75: u64;
-      let mut _76: u64;
-      let _77: ();
+      let mut _75: bool;
+      let _76: ();
+      let mut _77: u64;
       let mut _78: u64;
       let mut _79: u64;
-      let mut _80: u64;
-      let mut _81: u64;
-      let mut _82: bool;
+      let mut _80: bool;
+      let _81: ();
+      let mut _82: u64;
       let mut _83: u64;
-      let _84: ();
-      let mut _85: u64;
+      let mut _84: u64;
+      let _85: ();
       let mut _86: u64;
       let mut _87: u64;
       let mut _88: u64;
-      let mut _89: bool;
+      let _89: ();
       let mut _90: u64;
-      let _91: ();
+      let mut _91: u64;
       let mut _92: u64;
-      let mut _93: u64;
+      let _93: ();
       let mut _94: u64;
       let mut _95: u64;
       let mut _96: u64;
@@ -103,93 +103,91 @@
       let mut _98: u64;
       let mut _99: u64;
       let mut _100: u64;
-      let mut _101: u64;
-      let mut _102: u64;
-      let _103: ();
-      let mut _104: u64;
-      let mut _105: u64;
+      let _101: ();
+      let mut _102: u32;
+      let mut _103: u64;
+      let _104: ();
+      let mut _105: f32;
       let mut _106: u64;
-      let mut _107: u64;
-      let mut _108: u64;
-      let _109: ();
-      let mut _110: u64;
+      let _107: ();
+      let mut _108: S<u64>;
+      let mut _109: u64;
+      let _110: ();
       let mut _111: u64;
-      let mut _112: u64;
+      let mut _112: S<u64>;
       let mut _113: u64;
-      let mut _114: u64;
-      let _115: ();
+      let _114: ();
+      let mut _115: u64;
       let mut _116: u64;
       let mut _117: u64;
       let mut _118: u64;
       let mut _119: u64;
-      let mut _120: u64;
-      let _121: ();
-      let mut _122: S<u64>;
+      let _120: ();
+      let mut _121: u64;
+      let mut _122: u64;
       let mut _123: u64;
-      let _124: ();
+      let mut _124: u64;
       let mut _125: u64;
-      let mut _126: S<u64>;
-      let mut _127: u64;
-      let _128: &u64;
-      let _129: ();
+      let _126: &u64;
+      let _127: ();
+      let mut _128: u64;
+      let mut _129: u64;
       let mut _130: u64;
-      let mut _131: u64;
+      let _131: ();
       let mut _132: u64;
-      let _133: ();
+      let mut _133: u64;
       let mut _134: u64;
-      let mut _135: u64;
-      let mut _136: u64;
-      let _138: ();
+      let _136: ();
+      let mut _137: u64;
+      let mut _138: u64;
       let mut _139: u64;
-      let mut _140: u64;
+      let _140: ();
       let mut _141: u64;
-      let _142: ();
+      let mut _142: u64;
       let mut _143: u64;
-      let mut _144: u64;
-      let mut _145: u64;
+      let _144: ();
       let _146: ();
-      let _148: ();
+      let mut _147: u64;
+      let mut _148: u64;
       let mut _149: u64;
-      let mut _150: u64;
+      let _150: ();
       let mut _151: u64;
-      let _152: ();
+      let mut _152: u64;
       let mut _153: u64;
-      let mut _154: u64;
-      let mut _155: u64;
-      let _157: ();
+      let _155: ();
+      let mut _156: u64;
+      let mut _157: u64;
       let mut _158: u64;
-      let mut _159: u64;
+      let _159: ();
       let mut _160: u64;
-      let _161: ();
+      let mut _161: u64;
       let mut _162: u64;
-      let mut _163: u64;
-      let mut _164: u64;
-      let _166: ();
+      let _164: ();
+      let mut _165: u64;
+      let mut _166: u64;
       let mut _167: u64;
-      let mut _168: u64;
+      let _168: ();
       let mut _169: u64;
-      let _170: ();
+      let mut _170: u64;
       let mut _171: u64;
-      let mut _172: u64;
-      let mut _173: u64;
       scope 1 {
-          debug a => _128;
-          let _137: &mut u64;
+          debug a => _126;
+          let _135: &mut u64;
           scope 2 {
-              debug b => _137;
-              let _165: &u64;
+              debug b => _135;
+              let _163: &u64;
               scope 3 {
-                  let _147: *const u64;
+                  let _145: *const u64;
                   scope 4 {
-                      debug c => _147;
-                      let _156: *mut u64;
+                      debug c => _145;
+                      let _154: *mut u64;
                       scope 5 {
-                          debug d => _156;
+                          debug d => _154;
                       }
                   }
               }
               scope 6 {
-                  debug e => _165;
+                  debug e => _163;
               }
           }
       }
@@ -197,61 +195,68 @@
       bb0: {
           StorageLive(_4);
 -         StorageLive(_5);
--         StorageLive(_6);
--         _6 = _1;
--         StorageLive(_7);
--         _7 = _2;
++         nop;
+          StorageLive(_6);
+          _6 = _1;
+          StorageLive(_7);
+          _7 = _2;
 -         _5 = Add(move _6, move _7);
--         StorageDead(_7);
--         StorageDead(_6);
--         _4 = opaque::<u64>(move _5) -> [return: bb1, unwind continue];
 +         _5 = Add(_1, _2);
+          StorageDead(_7);
+          StorageDead(_6);
+-         _4 = opaque::<u64>(move _5) -> [return: bb1, unwind continue];
 +         _4 = opaque::<u64>(_5) -> [return: bb1, unwind continue];
       }
   
       bb1: {
 -         StorageDead(_5);
++         nop;
           StorageDead(_4);
           StorageLive(_8);
 -         StorageLive(_9);
--         StorageLive(_10);
--         _10 = _1;
--         StorageLive(_11);
--         _11 = _2;
++         nop;
+          StorageLive(_10);
+          _10 = _1;
+          StorageLive(_11);
+          _11 = _2;
 -         _9 = Mul(move _10, move _11);
--         StorageDead(_11);
--         StorageDead(_10);
--         _8 = opaque::<u64>(move _9) -> [return: bb2, unwind continue];
 +         _9 = Mul(_1, _2);
+          StorageDead(_11);
+          StorageDead(_10);
+-         _8 = opaque::<u64>(move _9) -> [return: bb2, unwind continue];
 +         _8 = opaque::<u64>(_9) -> [return: bb2, unwind continue];
       }
   
       bb2: {
 -         StorageDead(_9);
++         nop;
           StorageDead(_8);
           StorageLive(_12);
 -         StorageLive(_13);
--         StorageLive(_14);
--         _14 = _1;
--         StorageLive(_15);
--         _15 = _2;
++         nop;
+          StorageLive(_14);
+          _14 = _1;
+          StorageLive(_15);
+          _15 = _2;
 -         _13 = Sub(move _14, move _15);
--         StorageDead(_15);
--         StorageDead(_14);
--         _12 = opaque::<u64>(move _13) -> [return: bb3, unwind continue];
 +         _13 = Sub(_1, _2);
+          StorageDead(_15);
+          StorageDead(_14);
+-         _12 = opaque::<u64>(move _13) -> [return: bb3, unwind continue];
 +         _12 = opaque::<u64>(_13) -> [return: bb3, unwind continue];
       }
   
       bb3: {
 -         StorageDead(_13);
++         nop;
           StorageDead(_12);
           StorageLive(_16);
 -         StorageLive(_17);
--         StorageLive(_18);
--         _18 = _1;
--         StorageLive(_19);
--         _19 = _2;
++         nop;
+          StorageLive(_18);
+          _18 = _1;
+          StorageLive(_19);
+          _19 = _2;
 -         _20 = Eq(_19, const 0_u64);
 -         assert(!move _20, "attempt to divide `{}` by zero", _18) -> [success: bb4, unwind continue];
 +         _20 = Eq(_2, const 0_u64);
@@ -260,623 +265,701 @@
   
       bb4: {
 -         _17 = Div(move _18, move _19);
--         StorageDead(_19);
--         StorageDead(_18);
--         _16 = opaque::<u64>(move _17) -> [return: bb5, unwind continue];
 +         _17 = Div(_1, _2);
+          StorageDead(_19);
+          StorageDead(_18);
+-         _16 = opaque::<u64>(move _17) -> [return: bb5, unwind continue];
 +         _16 = opaque::<u64>(_17) -> [return: bb5, unwind continue];
       }
   
       bb5: {
 -         StorageDead(_17);
++         nop;
           StorageDead(_16);
           StorageLive(_21);
 -         StorageLive(_22);
--         StorageLive(_23);
--         _23 = _1;
--         StorageLive(_24);
--         _24 = _2;
++         nop;
+          StorageLive(_23);
+          _23 = _1;
+          StorageLive(_24);
+          _24 = _2;
 -         _25 = Eq(_24, const 0_u64);
 -         assert(!move _25, "attempt to calculate the remainder of `{}` with a divisor of zero", _23) -> [success: bb6, unwind continue];
++         _25 = _20;
 +         assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb6, unwind continue];
       }
   
       bb6: {
 -         _22 = Rem(move _23, move _24);
--         StorageDead(_24);
--         StorageDead(_23);
--         _21 = opaque::<u64>(move _22) -> [return: bb7, unwind continue];
 +         _22 = Rem(_1, _2);
+          StorageDead(_24);
+          StorageDead(_23);
+-         _21 = opaque::<u64>(move _22) -> [return: bb7, unwind continue];
 +         _21 = opaque::<u64>(_22) -> [return: bb7, unwind continue];
       }
   
       bb7: {
 -         StorageDead(_22);
++         nop;
           StorageDead(_21);
           StorageLive(_26);
 -         StorageLive(_27);
--         StorageLive(_28);
--         _28 = _1;
--         StorageLive(_29);
--         _29 = _2;
++         nop;
+          StorageLive(_28);
+          _28 = _1;
+          StorageLive(_29);
+          _29 = _2;
 -         _27 = BitAnd(move _28, move _29);
--         StorageDead(_29);
--         StorageDead(_28);
--         _26 = opaque::<u64>(move _27) -> [return: bb8, unwind continue];
 +         _27 = BitAnd(_1, _2);
+          StorageDead(_29);
+          StorageDead(_28);
+-         _26 = opaque::<u64>(move _27) -> [return: bb8, unwind continue];
 +         _26 = opaque::<u64>(_27) -> [return: bb8, unwind continue];
       }
   
       bb8: {
 -         StorageDead(_27);
++         nop;
           StorageDead(_26);
           StorageLive(_30);
 -         StorageLive(_31);
--         StorageLive(_32);
--         _32 = _1;
--         StorageLive(_33);
--         _33 = _2;
++         nop;
+          StorageLive(_32);
+          _32 = _1;
+          StorageLive(_33);
+          _33 = _2;
 -         _31 = BitOr(move _32, move _33);
--         StorageDead(_33);
--         StorageDead(_32);
--         _30 = opaque::<u64>(move _31) -> [return: bb9, unwind continue];
 +         _31 = BitOr(_1, _2);
+          StorageDead(_33);
+          StorageDead(_32);
+-         _30 = opaque::<u64>(move _31) -> [return: bb9, unwind continue];
 +         _30 = opaque::<u64>(_31) -> [return: bb9, unwind continue];
       }
   
       bb9: {
 -         StorageDead(_31);
++         nop;
           StorageDead(_30);
           StorageLive(_34);
 -         StorageLive(_35);
--         StorageLive(_36);
--         _36 = _1;
--         StorageLive(_37);
--         _37 = _2;
++         nop;
+          StorageLive(_36);
+          _36 = _1;
+          StorageLive(_37);
+          _37 = _2;
 -         _35 = BitXor(move _36, move _37);
--         StorageDead(_37);
--         StorageDead(_36);
--         _34 = opaque::<u64>(move _35) -> [return: bb10, unwind continue];
 +         _35 = BitXor(_1, _2);
+          StorageDead(_37);
+          StorageDead(_36);
+-         _34 = opaque::<u64>(move _35) -> [return: bb10, unwind continue];
 +         _34 = opaque::<u64>(_35) -> [return: bb10, unwind continue];
       }
   
       bb10: {
 -         StorageDead(_35);
++         nop;
           StorageDead(_34);
           StorageLive(_38);
 -         StorageLive(_39);
--         StorageLive(_40);
--         _40 = _1;
--         StorageLive(_41);
--         _41 = _2;
++         nop;
+          StorageLive(_40);
+          _40 = _1;
+          StorageLive(_41);
+          _41 = _2;
 -         _39 = Shl(move _40, move _41);
--         StorageDead(_41);
--         StorageDead(_40);
--         _38 = opaque::<u64>(move _39) -> [return: bb11, unwind continue];
 +         _39 = Shl(_1, _2);
+          StorageDead(_41);
+          StorageDead(_40);
+-         _38 = opaque::<u64>(move _39) -> [return: bb11, unwind continue];
 +         _38 = opaque::<u64>(_39) -> [return: bb11, unwind continue];
       }
   
       bb11: {
 -         StorageDead(_39);
++         nop;
           StorageDead(_38);
           StorageLive(_42);
 -         StorageLive(_43);
--         StorageLive(_44);
--         _44 = _1;
--         StorageLive(_45);
--         _45 = _2;
++         nop;
+          StorageLive(_44);
+          _44 = _1;
+          StorageLive(_45);
+          _45 = _2;
 -         _43 = Shr(move _44, move _45);
--         StorageDead(_45);
--         StorageDead(_44);
--         _42 = opaque::<u64>(move _43) -> [return: bb12, unwind continue];
 +         _43 = Shr(_1, _2);
+          StorageDead(_45);
+          StorageDead(_44);
+-         _42 = opaque::<u64>(move _43) -> [return: bb12, unwind continue];
 +         _42 = opaque::<u64>(_43) -> [return: bb12, unwind continue];
       }
   
       bb12: {
 -         StorageDead(_43);
++         nop;
           StorageDead(_42);
           StorageLive(_46);
-          StorageLive(_47);
--         StorageLive(_48);
--         _48 = _1;
+-         StorageLive(_47);
++         nop;
+          StorageLive(_48);
+          _48 = _1;
 -         _47 = move _48 as u32 (IntToInt);
--         StorageDead(_48);
 +         _47 = _1 as u32 (IntToInt);
-          _46 = opaque::<u32>(move _47) -> [return: bb13, unwind continue];
+          StorageDead(_48);
+-         _46 = opaque::<u32>(move _47) -> [return: bb13, unwind continue];
++         _46 = opaque::<u32>(_47) -> [return: bb13, unwind continue];
       }
   
       bb13: {
-          StorageDead(_47);
+-         StorageDead(_47);
++         nop;
           StorageDead(_46);
           StorageLive(_49);
-          StorageLive(_50);
--         StorageLive(_51);
--         _51 = _1;
+-         StorageLive(_50);
++         nop;
+          StorageLive(_51);
+          _51 = _1;
 -         _50 = move _51 as f32 (IntToFloat);
--         StorageDead(_51);
 +         _50 = _1 as f32 (IntToFloat);
-          _49 = opaque::<f32>(move _50) -> [return: bb14, unwind continue];
+          StorageDead(_51);
+-         _49 = opaque::<f32>(move _50) -> [return: bb14, unwind continue];
++         _49 = opaque::<f32>(_50) -> [return: bb14, unwind continue];
       }
   
       bb14: {
-          StorageDead(_50);
+-         StorageDead(_50);
++         nop;
           StorageDead(_49);
           StorageLive(_52);
 -         StorageLive(_53);
--         StorageLive(_54);
--         _54 = _1;
++         nop;
+          StorageLive(_54);
+          _54 = _1;
 -         _53 = S::<u64>(move _54);
--         StorageDead(_54);
--         _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind continue];
 +         _53 = S::<u64>(_1);
+          StorageDead(_54);
+-         _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind continue];
 +         _52 = opaque::<S<u64>>(_53) -> [return: bb15, unwind continue];
       }
   
       bb15: {
 -         StorageDead(_53);
++         nop;
           StorageDead(_52);
           StorageLive(_55);
--         StorageLive(_56);
--         StorageLive(_57);
--         StorageLive(_58);
--         _58 = _1;
+          StorageLive(_56);
+          StorageLive(_57);
+          StorageLive(_58);
+          _58 = _1;
 -         _57 = S::<u64>(move _58);
--         StorageDead(_58);
++         _57 = _53;
+          StorageDead(_58);
 -         _56 = (_57.0: u64);
 -         _55 = opaque::<u64>(move _56) -> [return: bb16, unwind continue];
-+         _56 = (_53.0: u64);
-+         _55 = opaque::<u64>(_56) -> [return: bb16, unwind continue];
++         _56 = _1;
++         _55 = opaque::<u64>(_1) -> [return: bb16, unwind continue];
       }
   
       bb16: {
--         StorageDead(_56);
--         StorageDead(_57);
+          StorageDead(_56);
+          StorageDead(_57);
           StorageDead(_55);
           StorageLive(_59);
           StorageLive(_60);
--         StorageLive(_61);
--         StorageLive(_62);
--         _62 = _1;
--         StorageLive(_63);
--         _63 = _2;
--         _61 = Add(move _62, move _63);
--         StorageDead(_63);
--         StorageDead(_62);
-          StorageLive(_64);
-          _64 = _3;
--         _60 = Add(move _61, move _64);
-+         _60 = Add(_5, move _64);
-          StorageDead(_64);
--         StorageDead(_61);
-          _59 = opaque::<u64>(move _60) -> [return: bb17, unwind continue];
+          StorageLive(_61);
+          _61 = _1;
+          StorageLive(_62);
+          _62 = _2;
+-         _60 = Add(move _61, move _62);
++         _60 = _5;
+          StorageDead(_62);
+          StorageDead(_61);
+-         _59 = opaque::<u64>(move _60) -> [return: bb17, unwind continue];
++         _59 = opaque::<u64>(_5) -> [return: bb17, unwind continue];
       }
   
       bb17: {
           StorageDead(_60);
           StorageDead(_59);
+          StorageLive(_63);
+          StorageLive(_64);
           StorageLive(_65);
+          _65 = _1;
           StorageLive(_66);
--         StorageLive(_67);
--         StorageLive(_68);
--         _68 = _1;
--         StorageLive(_69);
--         _69 = _2;
--         _67 = Mul(move _68, move _69);
--         StorageDead(_69);
--         StorageDead(_68);
+          _66 = _2;
+-         _64 = Mul(move _65, move _66);
++         _64 = _9;
+          StorageDead(_66);
+          StorageDead(_65);
+-         _63 = opaque::<u64>(move _64) -> [return: bb18, unwind continue];
++         _63 = opaque::<u64>(_9) -> [return: bb18, unwind continue];
+      }
+  
+      bb18: {
+          StorageDead(_64);
+          StorageDead(_63);
+          StorageLive(_67);
+          StorageLive(_68);
+          StorageLive(_69);
+          _69 = _1;
           StorageLive(_70);
-          _70 = _3;
--         _66 = Add(move _67, move _70);
-+         _66 = Add(_9, move _70);
+          _70 = _2;
+-         _68 = Sub(move _69, move _70);
++         _68 = _13;
           StorageDead(_70);
--         StorageDead(_67);
-          _65 = opaque::<u64>(move _66) -> [return: bb18, unwind continue];
+          StorageDead(_69);
+-         _67 = opaque::<u64>(move _68) -> [return: bb19, unwind continue];
++         _67 = opaque::<u64>(_13) -> [return: bb19, unwind continue];
       }
   
-      bb18: {
-          StorageDead(_66);
-          StorageDead(_65);
+      bb19: {
+          StorageDead(_68);
+          StorageDead(_67);
           StorageLive(_71);
           StorageLive(_72);
--         StorageLive(_73);
--         StorageLive(_74);
--         _74 = _1;
--         StorageLive(_75);
--         _75 = _2;
--         _73 = Sub(move _74, move _75);
--         StorageDead(_75);
--         StorageDead(_74);
-          StorageLive(_76);
-          _76 = _3;
--         _72 = Add(move _73, move _76);
-+         _72 = Add(_13, move _76);
-          StorageDead(_76);
--         StorageDead(_73);
-          _71 = opaque::<u64>(move _72) -> [return: bb19, unwind continue];
+          StorageLive(_73);
+          _73 = _1;
+          StorageLive(_74);
+          _74 = _2;
+-         _75 = Eq(_74, const 0_u64);
+-         assert(!move _75, "attempt to divide `{}` by zero", _73) -> [success: bb20, unwind continue];
++         _75 = _20;
++         assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind continue];
       }
   
-      bb19: {
+      bb20: {
+-         _72 = Div(move _73, move _74);
++         _72 = _17;
+          StorageDead(_74);
+          StorageDead(_73);
+-         _71 = opaque::<u64>(move _72) -> [return: bb21, unwind continue];
++         _71 = opaque::<u64>(_17) -> [return: bb21, unwind continue];
+      }
+  
+      bb21: {
           StorageDead(_72);
           StorageDead(_71);
+          StorageLive(_76);
           StorageLive(_77);
           StorageLive(_78);
--         StorageLive(_79);
--         StorageLive(_80);
--         _80 = _1;
--         StorageLive(_81);
--         _81 = _2;
--         _82 = Eq(_81, const 0_u64);
--         assert(!move _82, "attempt to divide `{}` by zero", _80) -> [success: bb20, unwind continue];
-+         assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind continue];
+          _78 = _1;
+          StorageLive(_79);
+          _79 = _2;
+-         _80 = Eq(_79, const 0_u64);
+-         assert(!move _80, "attempt to calculate the remainder of `{}` with a divisor of zero", _78) -> [success: bb22, unwind continue];
++         _80 = _20;
++         assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind continue];
       }
   
-      bb20: {
--         _79 = Div(move _80, move _81);
--         StorageDead(_81);
--         StorageDead(_80);
-          StorageLive(_83);
-          _83 = _3;
--         _78 = Add(move _79, move _83);
-+         _78 = Add(_17, move _83);
-          StorageDead(_83);
--         StorageDead(_79);
-          _77 = opaque::<u64>(move _78) -> [return: bb21, unwind continue];
+      bb22: {
+-         _77 = Rem(move _78, move _79);
++         _77 = _22;
+          StorageDead(_79);
+          StorageDead(_78);
+-         _76 = opaque::<u64>(move _77) -> [return: bb23, unwind continue];
++         _76 = opaque::<u64>(_22) -> [return: bb23, unwind continue];
       }
   
-      bb21: {
-          StorageDead(_78);
+      bb23: {
           StorageDead(_77);
+          StorageDead(_76);
+          StorageLive(_81);
+          StorageLive(_82);
+          StorageLive(_83);
+          _83 = _1;
           StorageLive(_84);
-          StorageLive(_85);
--         StorageLive(_86);
--         StorageLive(_87);
--         _87 = _1;
--         StorageLive(_88);
--         _88 = _2;
--         _89 = Eq(_88, const 0_u64);
--         assert(!move _89, "attempt to calculate the remainder of `{}` with a divisor of zero", _87) -> [success: bb22, unwind continue];
-+         assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind continue];
+          _84 = _2;
+-         _82 = BitAnd(move _83, move _84);
++         _82 = _27;
+          StorageDead(_84);
+          StorageDead(_83);
+-         _81 = opaque::<u64>(move _82) -> [return: bb24, unwind continue];
++         _81 = opaque::<u64>(_27) -> [return: bb24, unwind continue];
       }
   
-      bb22: {
--         _86 = Rem(move _87, move _88);
--         StorageDead(_88);
--         StorageDead(_87);
-          StorageLive(_90);
-          _90 = _3;
--         _85 = Add(move _86, move _90);
-+         _85 = Add(_22, move _90);
-          StorageDead(_90);
--         StorageDead(_86);
-          _84 = opaque::<u64>(move _85) -> [return: bb23, unwind continue];
+      bb24: {
+          StorageDead(_82);
+          StorageDead(_81);
+          StorageLive(_85);
+          StorageLive(_86);
+          StorageLive(_87);
+          _87 = _1;
+          StorageLive(_88);
+          _88 = _2;
+-         _86 = BitOr(move _87, move _88);
++         _86 = _31;
+          StorageDead(_88);
+          StorageDead(_87);
+-         _85 = opaque::<u64>(move _86) -> [return: bb25, unwind continue];
++         _85 = opaque::<u64>(_31) -> [return: bb25, unwind continue];
       }
   
-      bb23: {
+      bb25: {
+          StorageDead(_86);
           StorageDead(_85);
-          StorageDead(_84);
+          StorageLive(_89);
+          StorageLive(_90);
           StorageLive(_91);
+          _91 = _1;
           StorageLive(_92);
--         StorageLive(_93);
--         StorageLive(_94);
--         _94 = _1;
--         StorageLive(_95);
--         _95 = _2;
--         _93 = BitAnd(move _94, move _95);
--         StorageDead(_95);
--         StorageDead(_94);
+          _92 = _2;
+-         _90 = BitXor(move _91, move _92);
++         _90 = _35;
+          StorageDead(_92);
+          StorageDead(_91);
+-         _89 = opaque::<u64>(move _90) -> [return: bb26, unwind continue];
++         _89 = opaque::<u64>(_35) -> [return: bb26, unwind continue];
+      }
+  
+      bb26: {
+          StorageDead(_90);
+          StorageDead(_89);
+          StorageLive(_93);
+          StorageLive(_94);
+          StorageLive(_95);
+          _95 = _1;
           StorageLive(_96);
-          _96 = _3;
--         _92 = Add(move _93, move _96);
-+         _92 = Add(_27, move _96);
+          _96 = _2;
+-         _94 = Shl(move _95, move _96);
++         _94 = _39;
           StorageDead(_96);
--         StorageDead(_93);
-          _91 = opaque::<u64>(move _92) -> [return: bb24, unwind continue];
+          StorageDead(_95);
+-         _93 = opaque::<u64>(move _94) -> [return: bb27, unwind continue];
++         _93 = opaque::<u64>(_39) -> [return: bb27, unwind continue];
       }
   
-      bb24: {
-          StorageDead(_92);
-          StorageDead(_91);
+      bb27: {
+          StorageDead(_94);
+          StorageDead(_93);
           StorageLive(_97);
           StorageLive(_98);
--         StorageLive(_99);
--         StorageLive(_100);
--         _100 = _1;
--         StorageLive(_101);
--         _101 = _2;
--         _99 = BitOr(move _100, move _101);
--         StorageDead(_101);
--         StorageDead(_100);
-          StorageLive(_102);
-          _102 = _3;
--         _98 = Add(move _99, move _102);
-+         _98 = Add(_31, move _102);
-          StorageDead(_102);
--         StorageDead(_99);
-          _97 = opaque::<u64>(move _98) -> [return: bb25, unwind continue];
+          StorageLive(_99);
+          _99 = _1;
+          StorageLive(_100);
+          _100 = _2;
+-         _98 = Shr(move _99, move _100);
++         _98 = _43;
+          StorageDead(_100);
+          StorageDead(_99);
+-         _97 = opaque::<u64>(move _98) -> [return: bb28, unwind continue];
++         _97 = opaque::<u64>(_43) -> [return: bb28, unwind continue];
       }
   
-      bb25: {
+      bb28: {
           StorageDead(_98);
           StorageDead(_97);
+          StorageLive(_101);
+          StorageLive(_102);
           StorageLive(_103);
+          _103 = _1;
+-         _102 = move _103 as u32 (IntToInt);
++         _102 = _47;
+          StorageDead(_103);
+-         _101 = opaque::<u32>(move _102) -> [return: bb29, unwind continue];
++         _101 = opaque::<u32>(_47) -> [return: bb29, unwind continue];
+      }
+  
+      bb29: {
+          StorageDead(_102);
+          StorageDead(_101);
           StorageLive(_104);
--         StorageLive(_105);
--         StorageLive(_106);
--         _106 = _1;
--         StorageLive(_107);
--         _107 = _2;
--         _105 = BitXor(move _106, move _107);
--         StorageDead(_107);
--         StorageDead(_106);
-          StorageLive(_108);
-          _108 = _3;
--         _104 = Add(move _105, move _108);
-+         _104 = Add(_35, move _108);
-          StorageDead(_108);
--         StorageDead(_105);
-          _103 = opaque::<u64>(move _104) -> [return: bb26, unwind continue];
+          StorageLive(_105);
+          StorageLive(_106);
+          _106 = _1;
+-         _105 = move _106 as f32 (IntToFloat);
++         _105 = _50;
+          StorageDead(_106);
+-         _104 = opaque::<f32>(move _105) -> [return: bb30, unwind continue];
++         _104 = opaque::<f32>(_50) -> [return: bb30, unwind continue];
       }
   
-      bb26: {
+      bb30: {
+          StorageDead(_105);
           StorageDead(_104);
-          StorageDead(_103);
+          StorageLive(_107);
+          StorageLive(_108);
           StorageLive(_109);
+          _109 = _1;
+-         _108 = S::<u64>(move _109);
++         _108 = _53;
+          StorageDead(_109);
+-         _107 = opaque::<S<u64>>(move _108) -> [return: bb31, unwind continue];
++         _107 = opaque::<S<u64>>(_53) -> [return: bb31, unwind continue];
+      }
+  
+      bb31: {
+          StorageDead(_108);
+          StorageDead(_107);
           StorageLive(_110);
--         StorageLive(_111);
--         StorageLive(_112);
--         _112 = _1;
--         StorageLive(_113);
--         _113 = _2;
--         _111 = Shl(move _112, move _113);
--         StorageDead(_113);
--         StorageDead(_112);
-          StorageLive(_114);
-          _114 = _3;
--         _110 = Add(move _111, move _114);
-+         _110 = Add(_39, move _114);
-          StorageDead(_114);
--         StorageDead(_111);
-          _109 = opaque::<u64>(move _110) -> [return: bb27, unwind continue];
+          StorageLive(_111);
+          StorageLive(_112);
+          StorageLive(_113);
+          _113 = _1;
+-         _112 = S::<u64>(move _113);
++         _112 = _53;
+          StorageDead(_113);
+-         _111 = (_112.0: u64);
+-         _110 = opaque::<u64>(move _111) -> [return: bb32, unwind continue];
++         _111 = _1;
++         _110 = opaque::<u64>(_1) -> [return: bb32, unwind continue];
       }
   
-      bb27: {
+      bb32: {
+          StorageDead(_111);
+          StorageDead(_112);
           StorageDead(_110);
-          StorageDead(_109);
-          StorageLive(_115);
+          StorageLive(_114);
+-         StorageLive(_115);
++         nop;
           StorageLive(_116);
--         StorageLive(_117);
--         StorageLive(_118);
--         _118 = _1;
--         StorageLive(_119);
--         _119 = _2;
--         _117 = Shr(move _118, move _119);
--         StorageDead(_119);
--         StorageDead(_118);
-          StorageLive(_120);
-          _120 = _3;
--         _116 = Add(move _117, move _120);
-+         _116 = Add(_43, move _120);
-          StorageDead(_120);
--         StorageDead(_117);
-          _115 = opaque::<u64>(move _116) -> [return: bb28, unwind continue];
+          StorageLive(_117);
+          _117 = _1;
+          StorageLive(_118);
+          _118 = _2;
+-         _116 = Mul(move _117, move _118);
++         _116 = _9;
+          StorageDead(_118);
+          StorageDead(_117);
+          StorageLive(_119);
+          _119 = _2;
+-         _115 = Sub(move _116, move _119);
++         _115 = Sub(_9, _2);
+          StorageDead(_119);
+          StorageDead(_116);
+-         _114 = opaque::<u64>(move _115) -> [return: bb33, unwind continue];
++         _114 = opaque::<u64>(_115) -> [return: bb33, unwind continue];
       }
   
-      bb28: {
-          StorageDead(_116);
-          StorageDead(_115);
+      bb33: {
+-         StorageDead(_115);
++         nop;
+          StorageDead(_114);
+          StorageLive(_120);
           StorageLive(_121);
--         StorageLive(_122);
--         StorageLive(_123);
--         _123 = _1;
--         _122 = S::<u64>(move _123);
--         StorageDead(_123);
--         _121 = opaque::<S<u64>>(move _122) -> [return: bb29, unwind continue];
-+         _121 = opaque::<S<u64>>(_53) -> [return: bb29, unwind continue];
+          StorageLive(_122);
+          StorageLive(_123);
+          _123 = _1;
+          StorageLive(_124);
+          _124 = _2;
+-         _122 = Mul(move _123, move _124);
++         _122 = _9;
+          StorageDead(_124);
+          StorageDead(_123);
+          StorageLive(_125);
+          _125 = _2;
+-         _121 = Sub(move _122, move _125);
++         _121 = _115;
+          StorageDead(_125);
+          StorageDead(_122);
+-         _120 = opaque::<u64>(move _121) -> [return: bb34, unwind continue];
++         _120 = opaque::<u64>(_115) -> [return: bb34, unwind continue];
       }
   
-      bb29: {
--         StorageDead(_122);
+      bb34: {
           StorageDead(_121);
-          StorageLive(_124);
--         StorageLive(_125);
+          StorageDead(_120);
 -         StorageLive(_126);
--         StorageLive(_127);
--         _127 = _1;
--         _126 = S::<u64>(move _127);
--         StorageDead(_127);
--         _125 = (_126.0: u64);
--         _124 = opaque::<u64>(move _125) -> [return: bb30, unwind continue];
-+         _124 = opaque::<u64>(_56) -> [return: bb30, unwind continue];
-      }
-  
-      bb30: {
--         StorageDead(_125);
--         StorageDead(_126);
-          StorageDead(_124);
-          StorageLive(_128);
-          _128 = &_3;
-          StorageLive(_129);
--         StorageLive(_130);
--         StorageLive(_131);
-          _131 = (*_128);
--         StorageLive(_132);
--         _132 = _1;
--         _130 = Add(move _131, move _132);
--         StorageDead(_132);
--         StorageDead(_131);
--         _129 = opaque::<u64>(move _130) -> [return: bb31, unwind continue];
-+         _130 = Add(_131, _1);
-+         _129 = opaque::<u64>(_130) -> [return: bb31, unwind continue];
++         nop;
+          _126 = &_3;
+          StorageLive(_127);
+-         StorageLive(_128);
+-         StorageLive(_129);
++         nop;
++         nop;
+          _129 = (*_126);
+          StorageLive(_130);
+          _130 = _1;
+-         _128 = Add(move _129, move _130);
++         _128 = Add(_129, _1);
+          StorageDead(_130);
+-         StorageDead(_129);
+-         _127 = opaque::<u64>(move _128) -> [return: bb35, unwind continue];
++         nop;
++         _127 = opaque::<u64>(_128) -> [return: bb35, unwind continue];
       }
   
-      bb31: {
--         StorageDead(_130);
-          StorageDead(_129);
+      bb35: {
+-         StorageDead(_128);
++         nop;
+          StorageDead(_127);
+          StorageLive(_131);
+          StorageLive(_132);
           StorageLive(_133);
--         StorageLive(_134);
--         StorageLive(_135);
--         _135 = (*_128);
--         StorageLive(_136);
--         _136 = _1;
--         _134 = Add(move _135, move _136);
--         StorageDead(_136);
--         StorageDead(_135);
--         _133 = opaque::<u64>(move _134) -> [return: bb32, unwind continue];
-+         _133 = opaque::<u64>(_130) -> [return: bb32, unwind continue];
+-         _133 = (*_126);
++         _133 = _129;
+          StorageLive(_134);
+          _134 = _1;
+-         _132 = Add(move _133, move _134);
++         _132 = _128;
+          StorageDead(_134);
+          StorageDead(_133);
+-         _131 = opaque::<u64>(move _132) -> [return: bb36, unwind continue];
++         _131 = opaque::<u64>(_128) -> [return: bb36, unwind continue];
       }
   
-      bb32: {
--         StorageDead(_134);
-          StorageDead(_133);
+      bb36: {
+          StorageDead(_132);
+          StorageDead(_131);
+-         StorageLive(_135);
++         nop;
+          _135 = &mut _3;
+          StorageLive(_136);
           StorageLive(_137);
-          _137 = &mut _3;
           StorageLive(_138);
+          _138 = (*_135);
           StorageLive(_139);
-          StorageLive(_140);
-          _140 = (*_137);
--         StorageLive(_141);
--         _141 = _1;
--         _139 = Add(move _140, move _141);
--         StorageDead(_141);
-+         _139 = Add(move _140, _1);
-          StorageDead(_140);
-          _138 = opaque::<u64>(move _139) -> [return: bb33, unwind continue];
-      }
-  
-      bb33: {
+          _139 = _1;
+-         _137 = Add(move _138, move _139);
++         _137 = Add(move _138, _1);
           StorageDead(_139);
           StorageDead(_138);
-          StorageLive(_142);
-          StorageLive(_143);
-          StorageLive(_144);
-          _144 = (*_137);
--         StorageLive(_145);
--         _145 = _1;
--         _143 = Add(move _144, move _145);
--         StorageDead(_145);
-+         _143 = Add(move _144, _1);
-          StorageDead(_144);
-          _142 = opaque::<u64>(move _143) -> [return: bb34, unwind continue];
+          _136 = opaque::<u64>(move _137) -> [return: bb37, unwind continue];
       }
   
-      bb34: {
+      bb37: {
+          StorageDead(_137);
+          StorageDead(_136);
+          StorageLive(_140);
+          StorageLive(_141);
+          StorageLive(_142);
+          _142 = (*_135);
+          StorageLive(_143);
+          _143 = _1;
+-         _141 = Add(move _142, move _143);
++         _141 = Add(move _142, _1);
           StorageDead(_143);
           StorageDead(_142);
--         StorageLive(_146);
+          _140 = opaque::<u64>(move _141) -> [return: bb38, unwind continue];
+      }
+  
+      bb38: {
+          StorageDead(_141);
+          StorageDead(_140);
+          StorageLive(_144);
+-         StorageLive(_145);
++         nop;
+          _145 = &raw const _3;
+          StorageLive(_146);
           StorageLive(_147);
-          _147 = &raw const _3;
           StorageLive(_148);
+          _148 = (*_145);
           StorageLive(_149);
-          StorageLive(_150);
-          _150 = (*_147);
--         StorageLive(_151);
--         _151 = _1;
--         _149 = Add(move _150, move _151);
--         StorageDead(_151);
-+         _149 = Add(move _150, _1);
-          StorageDead(_150);
-          _148 = opaque::<u64>(move _149) -> [return: bb35, unwind continue];
-      }
-  
-      bb35: {
+          _149 = _1;
+-         _147 = Add(move _148, move _149);
++         _147 = Add(move _148, _1);
           StorageDead(_149);
           StorageDead(_148);
-          StorageLive(_152);
-          StorageLive(_153);
-          StorageLive(_154);
-          _154 = (*_147);
--         StorageLive(_155);
--         _155 = _1;
--         _153 = Add(move _154, move _155);
--         StorageDead(_155);
-+         _153 = Add(move _154, _1);
-          StorageDead(_154);
-          _152 = opaque::<u64>(move _153) -> [return: bb36, unwind continue];
+          _146 = opaque::<u64>(move _147) -> [return: bb39, unwind continue];
       }
   
-      bb36: {
+      bb39: {
+          StorageDead(_147);
+          StorageDead(_146);
+          StorageLive(_150);
+          StorageLive(_151);
+          StorageLive(_152);
+          _152 = (*_145);
+          StorageLive(_153);
+          _153 = _1;
+-         _151 = Add(move _152, move _153);
++         _151 = Add(move _152, _1);
           StorageDead(_153);
           StorageDead(_152);
+          _150 = opaque::<u64>(move _151) -> [return: bb40, unwind continue];
+      }
+  
+      bb40: {
+          StorageDead(_151);
+          StorageDead(_150);
+-         StorageLive(_154);
++         nop;
+          _154 = &raw mut _3;
+          StorageLive(_155);
           StorageLive(_156);
-          _156 = &raw mut _3;
           StorageLive(_157);
+          _157 = (*_154);
           StorageLive(_158);
-          StorageLive(_159);
-          _159 = (*_156);
--         StorageLive(_160);
--         _160 = _1;
--         _158 = Add(move _159, move _160);
--         StorageDead(_160);
-+         _158 = Add(move _159, _1);
-          StorageDead(_159);
-          _157 = opaque::<u64>(move _158) -> [return: bb37, unwind continue];
-      }
-  
-      bb37: {
+          _158 = _1;
+-         _156 = Add(move _157, move _158);
++         _156 = Add(move _157, _1);
           StorageDead(_158);
           StorageDead(_157);
-          StorageLive(_161);
-          StorageLive(_162);
-          StorageLive(_163);
-          _163 = (*_156);
--         StorageLive(_164);
--         _164 = _1;
--         _162 = Add(move _163, move _164);
--         StorageDead(_164);
-+         _162 = Add(move _163, _1);
-          StorageDead(_163);
-          _161 = opaque::<u64>(move _162) -> [return: bb38, unwind continue];
+          _155 = opaque::<u64>(move _156) -> [return: bb41, unwind continue];
       }
   
-      bb38: {
+      bb41: {
+          StorageDead(_156);
+          StorageDead(_155);
+          StorageLive(_159);
+          StorageLive(_160);
+          StorageLive(_161);
+          _161 = (*_154);
+          StorageLive(_162);
+          _162 = _1;
+-         _160 = Add(move _161, move _162);
++         _160 = Add(move _161, _1);
           StorageDead(_162);
           StorageDead(_161);
--         _146 = const ();
-          StorageDead(_156);
-          StorageDead(_147);
--         StorageDead(_146);
-          StorageLive(_165);
-          _165 = &_3;
-          StorageLive(_166);
--         StorageLive(_167);
--         StorageLive(_168);
-          _168 = (*_165);
--         StorageLive(_169);
--         _169 = _1;
--         _167 = Add(move _168, move _169);
--         StorageDead(_169);
--         StorageDead(_168);
--         _166 = opaque::<u64>(move _167) -> [return: bb39, unwind continue];
-+         _167 = Add(_168, _1);
-+         _166 = opaque::<u64>(_167) -> [return: bb39, unwind continue];
+          _159 = opaque::<u64>(move _160) -> [return: bb42, unwind continue];
       }
   
-      bb39: {
--         StorageDead(_167);
-          StorageDead(_166);
+      bb42: {
+          StorageDead(_160);
+          StorageDead(_159);
+          _144 = const ();
+-         StorageDead(_154);
+-         StorageDead(_145);
++         nop;
++         nop;
+          StorageDead(_144);
+-         StorageLive(_163);
++         nop;
+          _163 = &_3;
+          StorageLive(_164);
+-         StorageLive(_165);
+-         StorageLive(_166);
++         nop;
++         nop;
+          _166 = (*_163);
+          StorageLive(_167);
+          _167 = _1;
+-         _165 = Add(move _166, move _167);
++         _165 = Add(_166, _1);
+          StorageDead(_167);
+-         StorageDead(_166);
+-         _164 = opaque::<u64>(move _165) -> [return: bb43, unwind continue];
++         nop;
++         _164 = opaque::<u64>(_165) -> [return: bb43, unwind continue];
+      }
+  
+      bb43: {
+-         StorageDead(_165);
++         nop;
+          StorageDead(_164);
+          StorageLive(_168);
+          StorageLive(_169);
           StorageLive(_170);
--         StorageLive(_171);
--         StorageLive(_172);
--         _172 = (*_165);
--         StorageLive(_173);
--         _173 = _1;
--         _171 = Add(move _172, move _173);
--         StorageDead(_173);
--         StorageDead(_172);
--         _170 = opaque::<u64>(move _171) -> [return: bb40, unwind continue];
-+         _170 = opaque::<u64>(_167) -> [return: bb40, unwind continue];
+-         _170 = (*_163);
++         _170 = _166;
+          StorageLive(_171);
+          _171 = _1;
+-         _169 = Add(move _170, move _171);
++         _169 = _165;
+          StorageDead(_171);
+          StorageDead(_170);
+-         _168 = opaque::<u64>(move _169) -> [return: bb44, unwind continue];
++         _168 = opaque::<u64>(_165) -> [return: bb44, unwind continue];
       }
   
-      bb40: {
--         StorageDead(_171);
-          StorageDead(_170);
+      bb44: {
+          StorageDead(_169);
+          StorageDead(_168);
           _0 = const ();
-          StorageDead(_165);
-          StorageDead(_137);
-          StorageDead(_128);
+-         StorageDead(_163);
+-         StorageDead(_135);
+-         StorageDead(_126);
++         nop;
++         nop;
++         nop;
           return;
       }
   }
diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff
index f33845502ad..62710ba8fbf 100644
--- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff
+++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff
@@ -15,13 +15,15 @@
   
       bb0: {
           StorageLive(_2);
--         StorageLive(_3);
--         _3 = _1;
+          StorageLive(_3);
+          _3 = _1;
 -         _2 = Option::<T>::Some(move _3);
--         StorageDead(_3);
 +         _2 = Option::<T>::Some(_1);
-          _4 = discriminant(_2);
-          switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2];
+          StorageDead(_3);
+-         _4 = discriminant(_2);
+-         switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2];
++         _4 = const 1_isize;
++         switchInt(const 1_isize) -> [0: bb1, 1: bb3, otherwise: bb2];
       }
   
       bb1: {
@@ -34,10 +36,12 @@
       }
   
       bb3: {
--         StorageLive(_5);
-          _5 = ((_2 as Some).0: T);
-          _0 = _5;
--         StorageDead(_5);
+          StorageLive(_5);
+-         _5 = ((_2 as Some).0: T);
+-         _0 = _5;
++         _5 = _1;
++         _0 = _1;
+          StorageDead(_5);
           StorageDead(_2);
           return;
       }
diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff
index edc05f99fe2..ad46a065b1e 100644
--- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff
+++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff
@@ -15,13 +15,15 @@
   
       bb0: {
           StorageLive(_2);
--         StorageLive(_3);
--         _3 = _1;
+          StorageLive(_3);
+          _3 = _1;
 -         _2 = Option::<T>::Some(move _3);
--         StorageDead(_3);
 +         _2 = Option::<T>::Some(_1);
-          _4 = discriminant(_2);
-          switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2];
+          StorageDead(_3);
+-         _4 = discriminant(_2);
+-         switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2];
++         _4 = const 1_isize;
++         switchInt(const 1_isize) -> [0: bb1, 1: bb3, otherwise: bb2];
       }
   
       bb1: {
@@ -34,10 +36,12 @@
       }
   
       bb3: {
--         StorageLive(_5);
-          _5 = ((_2 as Some).0: T);
-          _0 = _5;
--         StorageDead(_5);
+          StorageLive(_5);
+-         _5 = ((_2 as Some).0: T);
+-         _0 = _5;
++         _5 = _1;
++         _0 = _1;
+          StorageDead(_5);
           StorageDead(_2);
           return;
       }
diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff
index 9d8f272abea..b2539f391d1 100644
--- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff
+++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff
@@ -7,22 +7,18 @@
       let _2: &[T];
       let mut _3: &[T; 3];
       let _4: [T; 3];
-      let mut _5: T;
-      let mut _6: T;
-      let mut _7: T;
-      let mut _8: usize;
-      let mut _9: usize;
-      let mut _10: bool;
-      let mut _14: !;
+      let mut _5: usize;
+      let mut _6: bool;
+      let mut _10: !;
       scope 1 {
           debug v => _2;
-          let _11: &T;
-          let _12: &T;
-          let _13: &T;
+          let _7: &T;
+          let _8: &T;
+          let _9: &T;
           scope 2 {
-              debug v1 => _11;
-              debug v2 => _12;
-              debug v3 => _13;
+              debug v1 => _7;
+              debug v2 => _8;
+              debug v3 => _9;
           }
       }
   
@@ -33,26 +29,25 @@
           _3 = &_4;
           _2 = move _3 as &[T] (PointerCoercion(Unsize));
           StorageDead(_3);
-          _8 = const 3_usize;
-          _9 = const 3_usize;
-          _10 = const true;
+          _5 = const 3_usize;
+          _6 = const true;
           goto -> bb2;
       }
   
       bb1: {
-          _14 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable;
+          _10 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable;
       }
   
       bb2: {
-          StorageLive(_11);
-          _11 = &(*_2)[0 of 3];
-          StorageLive(_12);
-          _12 = &(*_2)[1 of 3];
-          StorageLive(_13);
-          _13 = &(*_2)[2 of 3];
-          StorageDead(_13);
-          StorageDead(_12);
-          StorageDead(_11);
+          StorageLive(_7);
+          _7 = &(*_2)[0 of 3];
+          StorageLive(_8);
+          _8 = &(*_2)[1 of 3];
+          StorageLive(_9);
+          _9 = &(*_2)[2 of 3];
+          StorageDead(_9);
+          StorageDead(_8);
+          StorageDead(_7);
           StorageDead(_4);
           return;
       }
diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff
index 738b0b1b3e5..ff7f12c093c 100644
--- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff
+++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff
@@ -7,22 +7,18 @@
       let _2: &[T];
       let mut _3: &[T; 3];
       let _4: [T; 3];
-      let mut _5: T;
-      let mut _6: T;
-      let mut _7: T;
-      let mut _8: usize;
-      let mut _9: usize;
-      let mut _10: bool;
-      let mut _14: !;
+      let mut _5: usize;
+      let mut _6: bool;
+      let mut _10: !;
       scope 1 {
           debug v => _2;
-          let _11: &T;
-          let _12: &T;
-          let _13: &T;
+          let _7: &T;
+          let _8: &T;
+          let _9: &T;
           scope 2 {
-              debug v1 => _11;
-              debug v2 => _12;
-              debug v3 => _13;
+              debug v1 => _7;
+              debug v2 => _8;
+              debug v3 => _9;
           }
       }
   
@@ -33,26 +29,25 @@
           _3 = &_4;
           _2 = move _3 as &[T] (PointerCoercion(Unsize));
           StorageDead(_3);
-          _8 = const 3_usize;
-          _9 = const 3_usize;
-          _10 = const true;
+          _5 = const 3_usize;
+          _6 = const true;
           goto -> bb2;
       }
   
       bb1: {
-          _14 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue;
+          _10 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue;
       }
   
       bb2: {
-          StorageLive(_11);
-          _11 = &(*_2)[0 of 3];
-          StorageLive(_12);
-          _12 = &(*_2)[1 of 3];
-          StorageLive(_13);
-          _13 = &(*_2)[2 of 3];
-          StorageDead(_13);
-          StorageDead(_12);
-          StorageDead(_11);
+          StorageLive(_7);
+          _7 = &(*_2)[0 of 3];
+          StorageLive(_8);
+          _8 = &(*_2)[1 of 3];
+          StorageLive(_9);
+          _9 = &(*_2)[2 of 3];
+          StorageDead(_9);
+          StorageDead(_8);
+          StorageDead(_7);
           StorageDead(_4);
           return;
       }
diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff
index d3957158360..64a435f2245 100644
--- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff
+++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff
@@ -3,18 +3,15 @@
   
   fn main() -> () {
       let mut _0: ();
-      let mut _1: bool;
-      let _2: ();
+      let _1: ();
   
       bb0: {
-          StorageLive(_1);
-          _1 = const false;
 -         switchInt(const false) -> [0: bb3, otherwise: bb1];
 +         goto -> bb3;
       }
   
       bb1: {
-          _2 = noop() -> [return: bb2, unwind unreachable];
+          _1 = noop() -> [return: bb2, unwind unreachable];
       }
   
       bb2: {
@@ -26,7 +23,6 @@
       }
   
       bb4: {
-          StorageDead(_1);
           return;
       }
   }
diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff
index 81903c64dbd..146e00686ed 100644
--- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff
+++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff
@@ -3,18 +3,15 @@
   
   fn main() -> () {
       let mut _0: ();
-      let mut _1: bool;
-      let _2: ();
+      let _1: ();
   
       bb0: {
-          StorageLive(_1);
-          _1 = const false;
 -         switchInt(const false) -> [0: bb3, otherwise: bb1];
 +         goto -> bb3;
       }
   
       bb1: {
-          _2 = noop() -> [return: bb2, unwind continue];
+          _1 = noop() -> [return: bb2, unwind continue];
       }
   
       bb2: {
@@ -26,7 +23,6 @@
       }
   
       bb4: {
-          StorageDead(_1);
           return;
       }
   }
diff --git a/tests/run-coverage/bad_counter_ids.coverage b/tests/run-coverage/bad_counter_ids.coverage
new file mode 100644
index 00000000000..d69ebf160ea
--- /dev/null
+++ b/tests/run-coverage/bad_counter_ids.coverage
@@ -0,0 +1,69 @@
+   LL|       |#![feature(coverage_attribute)]
+   LL|       |// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3
+   LL|       |
+   LL|       |// Regression test for <https://github.com/rust-lang/rust/issues/117012>.
+   LL|       |//
+   LL|       |// If some coverage counters were removed by MIR optimizations, we need to take
+   LL|       |// care not to refer to those counter IDs in coverage mappings, and instead
+   LL|       |// replace them with a constant zero value. If we don't, `llvm-cov` might see
+   LL|       |// a too-large counter ID and silently discard the entire function from its
+   LL|       |// coverage reports.
+   LL|       |
+   LL|      8|#[derive(Debug, PartialEq, Eq)]
+   LL|       |struct Foo(u32);
+   LL|       |
+   LL|      1|fn eq_good() {
+   LL|      1|    println!("a");
+   LL|      1|    assert_eq!(Foo(1), Foo(1));
+   LL|      1|}
+   LL|       |
+   LL|      1|fn eq_good_message() {
+   LL|      1|    println!("b");
+   LL|      1|    assert_eq!(Foo(1), Foo(1), "message b");
+                                             ^0
+   LL|      1|}
+   LL|       |
+   LL|      1|fn ne_good() {
+   LL|      1|    println!("c");
+   LL|      1|    assert_ne!(Foo(1), Foo(3));
+   LL|      1|}
+   LL|       |
+   LL|      1|fn ne_good_message() {
+   LL|      1|    println!("d");
+   LL|      1|    assert_ne!(Foo(1), Foo(3), "message d");
+                                             ^0
+   LL|      1|}
+   LL|       |
+   LL|      1|fn eq_bad() {
+   LL|      1|    println!("e");
+   LL|      1|    assert_eq!(Foo(1), Foo(3));
+   LL|      0|}
+   LL|       |
+   LL|      1|fn eq_bad_message() {
+   LL|      1|    println!("f");
+   LL|      1|    assert_eq!(Foo(1), Foo(3), "message f");
+   LL|      0|}
+   LL|       |
+   LL|      1|fn ne_bad() {
+   LL|      1|    println!("g");
+   LL|      1|    assert_ne!(Foo(1), Foo(1));
+   LL|      0|}
+   LL|       |
+   LL|      1|fn ne_bad_message() {
+   LL|      1|    println!("h");
+   LL|      1|    assert_ne!(Foo(1), Foo(1), "message h");
+   LL|      0|}
+   LL|       |
+   LL|       |#[coverage(off)]
+   LL|       |fn main() {
+   LL|       |    eq_good();
+   LL|       |    eq_good_message();
+   LL|       |    ne_good();
+   LL|       |    ne_good_message();
+   LL|       |
+   LL|       |    assert!(std::panic::catch_unwind(eq_bad).is_err());
+   LL|       |    assert!(std::panic::catch_unwind(eq_bad_message).is_err());
+   LL|       |    assert!(std::panic::catch_unwind(ne_bad).is_err());
+   LL|       |    assert!(std::panic::catch_unwind(ne_bad_message).is_err());
+   LL|       |}
+
diff --git a/tests/run-coverage/bad_counter_ids.rs b/tests/run-coverage/bad_counter_ids.rs
new file mode 100644
index 00000000000..ef5460102b7
--- /dev/null
+++ b/tests/run-coverage/bad_counter_ids.rs
@@ -0,0 +1,66 @@
+#![feature(coverage_attribute)]
+// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3
+
+// Regression test for <https://github.com/rust-lang/rust/issues/117012>.
+//
+// If some coverage counters were removed by MIR optimizations, we need to take
+// care not to refer to those counter IDs in coverage mappings, and instead
+// replace them with a constant zero value. If we don't, `llvm-cov` might see
+// a too-large counter ID and silently discard the entire function from its
+// coverage reports.
+
+#[derive(Debug, PartialEq, Eq)]
+struct Foo(u32);
+
+fn eq_good() {
+    println!("a");
+    assert_eq!(Foo(1), Foo(1));
+}
+
+fn eq_good_message() {
+    println!("b");
+    assert_eq!(Foo(1), Foo(1), "message b");
+}
+
+fn ne_good() {
+    println!("c");
+    assert_ne!(Foo(1), Foo(3));
+}
+
+fn ne_good_message() {
+    println!("d");
+    assert_ne!(Foo(1), Foo(3), "message d");
+}
+
+fn eq_bad() {
+    println!("e");
+    assert_eq!(Foo(1), Foo(3));
+}
+
+fn eq_bad_message() {
+    println!("f");
+    assert_eq!(Foo(1), Foo(3), "message f");
+}
+
+fn ne_bad() {
+    println!("g");
+    assert_ne!(Foo(1), Foo(1));
+}
+
+fn ne_bad_message() {
+    println!("h");
+    assert_ne!(Foo(1), Foo(1), "message h");
+}
+
+#[coverage(off)]
+fn main() {
+    eq_good();
+    eq_good_message();
+    ne_good();
+    ne_good_message();
+
+    assert!(std::panic::catch_unwind(eq_bad).is_err());
+    assert!(std::panic::catch_unwind(eq_bad_message).is_err());
+    assert!(std::panic::catch_unwind(ne_bad).is_err());
+    assert!(std::panic::catch_unwind(ne_bad_message).is_err());
+}
diff --git a/tests/ui/borrowck/alias-liveness/gat-static.rs b/tests/ui/borrowck/alias-liveness/gat-static.rs
new file mode 100644
index 00000000000..92153124af9
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/gat-static.rs
@@ -0,0 +1,29 @@
+// check-pass
+
+trait Foo {
+    type Assoc<'a>
+    where
+        Self: 'a;
+
+    fn assoc(&mut self) -> Self::Assoc<'_>;
+}
+
+fn overlapping_mut<T>(mut t: T)
+where
+    T: Foo,
+    for<'a> T::Assoc<'a>: 'static,
+{
+    let a = t.assoc();
+    let b = t.assoc();
+}
+
+fn live_past_borrow<T>(mut t: T)
+where
+    T: Foo,
+    for<'a> T::Assoc<'a>: 'static {
+    let x = t.assoc();
+    drop(t);
+    drop(x);
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.rs b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.rs
new file mode 100644
index 00000000000..1f26c7babf2
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.rs
@@ -0,0 +1,16 @@
+// known-bug: #42940
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+trait Outlives<'a>: 'a {}
+impl<'a, T: 'a> Outlives<'a> for T {}
+
+// Test that we treat `for<'a> Opaque: 'a` as `Opaque: 'static`
+fn test<'o>(v: &'o Vec<i32>) -> impl Captures<'o> + for<'a> Outlives<'a> {}
+
+fn statik() -> impl Sized {
+    test(&vec![])
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr
new file mode 100644
index 00000000000..58a42d8afe4
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr
@@ -0,0 +1,16 @@
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/higher-ranked-outlives-for-capture.rs:13:11
+   |
+LL |     test(&vec![])
+   |     ------^^^^^^-
+   |     |     |
+   |     |     creates a temporary value which is freed while still in use
+   |     argument requires that borrow lasts for `'static`
+LL | }
+   | - temporary value is freed at the end of this statement
+   |
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0716`.
diff --git a/tests/ui/borrowck/alias-liveness/higher-ranked.rs b/tests/ui/borrowck/alias-liveness/higher-ranked.rs
new file mode 100644
index 00000000000..afd0d3b31e3
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/higher-ranked.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+trait Outlives<'a>: 'a {}
+impl<'a, T: 'a> Outlives<'a> for T {}
+
+// Test that we treat `for<'a> Opaque: 'a` as `Opaque: 'static`
+fn test<'o>(v: &'o Vec<i32>) -> impl Captures<'o> + for<'a> Outlives<'a> {}
+
+fn opaque_doesnt_use_temporary() {
+    let a = test(&vec![]);
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/alias-liveness/opaque-capture.rs b/tests/ui/borrowck/alias-liveness/opaque-capture.rs
new file mode 100644
index 00000000000..f4ca2728bdb
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/opaque-capture.rs
@@ -0,0 +1,17 @@
+// check-pass
+
+// Check that opaques capturing early and late-bound vars correctly mark
+// regions required to be live using the item bounds.
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+fn captures_temp_late<'a>(x: &'a Vec<i32>) -> impl Sized + Captures<'a> + 'static {}
+fn captures_temp_early<'a: 'a>(x: &'a Vec<i32>) -> impl Sized + Captures<'a> + 'static {}
+
+fn test() {
+    let x = captures_temp_early(&vec![]);
+    let y = captures_temp_late(&vec![]);
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/alias-liveness/opaque-type-param.rs b/tests/ui/borrowck/alias-liveness/opaque-type-param.rs
new file mode 100644
index 00000000000..a292463b2ac
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/opaque-type-param.rs
@@ -0,0 +1,14 @@
+// known-bug: #42940
+
+trait Trait {}
+impl Trait for () {}
+
+fn foo<'a>(s: &'a str) -> impl Trait + 'static {
+    bar(s)
+}
+
+fn bar<P: AsRef<str>>(s: P) -> impl Trait + 'static {
+    ()
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr b/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr
new file mode 100644
index 00000000000..e1fbbc14f44
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr
@@ -0,0 +1,13 @@
+error[E0700]: hidden type for `impl Trait + 'static` captures lifetime that does not appear in bounds
+  --> $DIR/opaque-type-param.rs:7:5
+   |
+LL | fn foo<'a>(s: &'a str) -> impl Trait + 'static {
+   |        --                 -------------------- opaque type defined here
+   |        |
+   |        hidden type `impl Trait + 'static` captures the lifetime `'a` as defined here
+LL |     bar(s)
+   |     ^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/borrowck/alias-liveness/rpit-static.rs b/tests/ui/borrowck/alias-liveness/rpit-static.rs
new file mode 100644
index 00000000000..45da3edb878
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/rpit-static.rs
@@ -0,0 +1,22 @@
+// check-pass
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+fn foo(x: &mut i32) -> impl Sized + Captures<'_> + 'static {}
+
+fn overlapping_mut() {
+    let i = &mut 1;
+    let x = foo(i);
+    let y = foo(i);
+}
+
+fn live_past_borrow() {
+    let y;
+    {
+        let x = &mut 1;
+        y = foo(x);
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/alias-liveness/rpitit-static.rs b/tests/ui/borrowck/alias-liveness/rpitit-static.rs
new file mode 100644
index 00000000000..2cc68d2bf3d
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/rpitit-static.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+trait Foo {
+    fn rpitit(&mut self) -> impl Sized + 'static;
+}
+
+fn live_past_borrow<T: Foo>(mut t: T) {
+    let x = t.rpitit();
+    drop(t);
+    drop(x);
+}
+
+fn overlapping_mut<T: Foo>(mut t: T) {
+    let a = t.rpitit();
+    let b = t.rpitit();
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/alias-liveness/rtn-static.rs b/tests/ui/borrowck/alias-liveness/rtn-static.rs
new file mode 100644
index 00000000000..1f136b8b998
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/rtn-static.rs
@@ -0,0 +1,23 @@
+// check-pass
+
+#![feature(return_type_notation)]
+//~^ WARN the feature `return_type_notation` is incomplete
+
+trait Foo {
+    fn borrow(&mut self) -> impl Sized + '_;
+}
+
+fn live_past_borrow<T: Foo<borrow(): 'static>>(mut t: T) {
+    let x = t.borrow();
+    drop(t);
+    drop(x);
+}
+
+// Test that the `'_` item bound in `borrow` does not cause us to
+// overlook the `'static` RTN bound.
+fn overlapping_mut<T: Foo<borrow(): 'static>>(mut t: T) {
+    let x = t.borrow();
+    let x = t.borrow();
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/alias-liveness/rtn-static.stderr b/tests/ui/borrowck/alias-liveness/rtn-static.stderr
new file mode 100644
index 00000000000..e9202db2c79
--- /dev/null
+++ b/tests/ui/borrowck/alias-liveness/rtn-static.stderr
@@ -0,0 +1,11 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/rtn-static.rs:3:12
+   |
+LL | #![feature(return_type_notation)]
+   |            ^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs
index 078283fbd1f..72a0c9efed2 100644
--- a/tests/ui/consts/const-eval/ub-enum.rs
+++ b/tests/ui/consts/const-eval/ub-enum.rs
@@ -2,7 +2,7 @@
 // Strip out raw byte dumps to make comparison platform-independent:
 // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
 // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP"
-#![feature(never_type, const_discriminant)]
+#![feature(never_type)]
 #![allow(invalid_value)]
 
 use std::mem;
diff --git a/tests/ui/consts/const_discriminant.rs b/tests/ui/consts/const_discriminant.rs
index b1180faa697..80deb0f784d 100644
--- a/tests/ui/consts/const_discriminant.rs
+++ b/tests/ui/consts/const_discriminant.rs
@@ -1,5 +1,4 @@
 // run-pass
-#![feature(const_discriminant)]
 #![allow(dead_code)]
 
 use std::mem::{discriminant, Discriminant};
diff --git a/tests/ui/coroutine/gen_block.e2024.stderr b/tests/ui/coroutine/gen_block.e2024.stderr
new file mode 100644
index 00000000000..f250e2f79c7
--- /dev/null
+++ b/tests/ui/coroutine/gen_block.e2024.stderr
@@ -0,0 +1,19 @@
+error[E0658]: yield syntax is experimental
+  --> $DIR/gen_block.rs:15:16
+   |
+LL |     let _ = || yield true;
+   |                ^^^^^^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+
+error[E0282]: type annotations needed
+  --> $DIR/gen_block.rs:6:17
+   |
+LL |     let x = gen {};
+   |                 ^^ cannot infer type
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0282, E0658.
+For more information about an error, try `rustc --explain E0282`.
diff --git a/tests/ui/coroutine/gen_block.none.stderr b/tests/ui/coroutine/gen_block.none.stderr
new file mode 100644
index 00000000000..012a8308c7f
--- /dev/null
+++ b/tests/ui/coroutine/gen_block.none.stderr
@@ -0,0 +1,49 @@
+error: expected identifier, found reserved keyword `yield`
+  --> $DIR/gen_block.rs:9:19
+   |
+LL |     let y = gen { yield 42 };
+   |             ---   ^^^^^ expected identifier, found reserved keyword
+   |             |
+   |             while parsing this struct
+
+error[E0422]: cannot find struct, variant or union type `gen` in this scope
+  --> $DIR/gen_block.rs:6:13
+   |
+LL |     let x = gen {};
+   |             ^^^ not found in this scope
+
+error[E0422]: cannot find struct, variant or union type `gen` in this scope
+  --> $DIR/gen_block.rs:9:13
+   |
+LL |     let y = gen { yield 42 };
+   |             ^^^ not found in this scope
+
+error[E0422]: cannot find struct, variant or union type `gen` in this scope
+  --> $DIR/gen_block.rs:12:5
+   |
+LL |     gen {};
+   |     ^^^ not found in this scope
+
+error[E0658]: yield syntax is experimental
+  --> $DIR/gen_block.rs:15:16
+   |
+LL |     let _ = || yield true;
+   |                ^^^^^^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+
+error[E0658]: yield syntax is experimental
+  --> $DIR/gen_block.rs:15:16
+   |
+LL |     let _ = || yield true;
+   |                ^^^^^^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0422, E0658.
+For more information about an error, try `rustc --explain E0422`.
diff --git a/tests/ui/coroutine/gen_block.rs b/tests/ui/coroutine/gen_block.rs
new file mode 100644
index 00000000000..852c7c455a6
--- /dev/null
+++ b/tests/ui/coroutine/gen_block.rs
@@ -0,0 +1,17 @@
+// revisions: e2024 none
+//[e2024] compile-flags: --edition 2024 -Zunstable-options
+#![cfg_attr(e2024, feature(gen_blocks))]
+
+fn main() {
+    let x = gen {};
+    //[none]~^ ERROR: cannot find
+    //[e2024]~^^ ERROR: type annotations needed
+    let y = gen { yield 42 };
+    //[none]~^ ERROR: found reserved keyword `yield`
+    //[none]~| ERROR: cannot find
+    gen {};
+    //[none]~^ ERROR: cannot find
+
+    let _ = || yield true; //[none]~ ERROR yield syntax is experimental
+    //~^ ERROR yield syntax is experimental
+}
diff --git a/tests/ui/coroutine/gen_block_is_coro.rs b/tests/ui/coroutine/gen_block_is_coro.rs
new file mode 100644
index 00000000000..c66ccefba85
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_is_coro.rs
@@ -0,0 +1,18 @@
+//compile-flags: --edition 2024 -Zunstable-options
+#![feature(coroutines, coroutine_trait, gen_blocks)]
+
+use std::ops::Coroutine;
+
+fn foo() -> impl Coroutine<Yield = u32, Return = ()> { //~ ERROR: Coroutine` is not satisfied
+    gen { yield 42 }
+}
+
+fn bar() -> impl Coroutine<Yield = i64, Return = ()> { //~ ERROR: Coroutine` is not satisfied
+    gen { yield 42 }
+}
+
+fn baz() -> impl Coroutine<Yield = i32, Return = ()> { //~ ERROR: Coroutine` is not satisfied
+    gen { yield 42 }
+}
+
+fn main() {}
diff --git a/tests/ui/coroutine/gen_block_is_coro.stderr b/tests/ui/coroutine/gen_block_is_coro.stderr
new file mode 100644
index 00000000000..83a674fa53c
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_is_coro.stderr
@@ -0,0 +1,21 @@
+error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:21}: Coroutine` is not satisfied
+  --> $DIR/gen_block_is_coro.rs:6:13
+   |
+LL | fn foo() -> impl Coroutine<Yield = u32, Return = ()> {
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:21}`
+
+error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:11:5: 11:21}: Coroutine` is not satisfied
+  --> $DIR/gen_block_is_coro.rs:10:13
+   |
+LL | fn bar() -> impl Coroutine<Yield = i64, Return = ()> {
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:11:5: 11:21}`
+
+error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:15:5: 15:21}: Coroutine` is not satisfied
+  --> $DIR/gen_block_is_coro.rs:14:13
+   |
+LL | fn baz() -> impl Coroutine<Yield = i32, Return = ()> {
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:15:5: 15:21}`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/coroutine/gen_block_is_iter.rs b/tests/ui/coroutine/gen_block_is_iter.rs
new file mode 100644
index 00000000000..92625cf7c28
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_is_iter.rs
@@ -0,0 +1,19 @@
+// revisions: next old
+//compile-flags: --edition 2024 -Zunstable-options
+//[next] compile-flags: -Ztrait-solver=next
+// check-pass
+#![feature(gen_blocks)]
+
+fn foo() -> impl Iterator<Item = u32> {
+    gen { yield 42 }
+}
+
+fn bar() -> impl Iterator<Item = i64> {
+    gen { yield 42 }
+}
+
+fn baz() -> impl Iterator<Item = i32> {
+    gen { yield 42 }
+}
+
+fn main() {}
diff --git a/tests/ui/coroutine/gen_block_is_no_future.rs b/tests/ui/coroutine/gen_block_is_no_future.rs
new file mode 100644
index 00000000000..94766519738
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_is_no_future.rs
@@ -0,0 +1,8 @@
+//compile-flags: --edition 2024 -Zunstable-options
+#![feature(gen_blocks)]
+
+fn foo() -> impl std::future::Future { //~ ERROR is not a future
+    gen { yield 42 }
+}
+
+fn main() {}
diff --git a/tests/ui/coroutine/gen_block_is_no_future.stderr b/tests/ui/coroutine/gen_block_is_no_future.stderr
new file mode 100644
index 00000000000..db0c3c19b58
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_is_no_future.stderr
@@ -0,0 +1,12 @@
+error[E0277]: `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}` is not a future
+  --> $DIR/gen_block_is_no_future.rs:4:13
+   |
+LL | fn foo() -> impl std::future::Future {
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^ `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}` is not a future
+   |
+   = help: the trait `Future` is not implemented for `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}`
+   = note: {gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21} must be a future or must implement `IntoFuture` to be awaited
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/coroutine/gen_block_iterate.rs b/tests/ui/coroutine/gen_block_iterate.rs
new file mode 100644
index 00000000000..18e1bb88772
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_iterate.rs
@@ -0,0 +1,35 @@
+// revisions: next old
+//compile-flags: --edition 2024 -Zunstable-options
+//[next] compile-flags: -Ztrait-solver=next
+// run-pass
+#![feature(gen_blocks)]
+
+fn foo() -> impl Iterator<Item = u32> {
+    gen { yield 42; for x in 3..6 { yield x } }
+}
+
+fn moved() -> impl Iterator<Item = u32> {
+    let mut x = "foo".to_string();
+    gen move {
+        yield 42;
+        if x == "foo" { return }
+        x.clear();
+        for x in 3..6 { yield x }
+    }
+}
+
+fn main() {
+    let mut iter = foo();
+    assert_eq!(iter.next(), Some(42));
+    assert_eq!(iter.next(), Some(3));
+    assert_eq!(iter.next(), Some(4));
+    assert_eq!(iter.next(), Some(5));
+    assert_eq!(iter.next(), None);
+    // `gen` blocks are fused
+    assert_eq!(iter.next(), None);
+
+    let mut iter = moved();
+    assert_eq!(iter.next(), Some(42));
+    assert_eq!(iter.next(), None);
+
+}
diff --git a/tests/ui/coroutine/gen_block_move.fixed b/tests/ui/coroutine/gen_block_move.fixed
new file mode 100644
index 00000000000..5c6c8062322
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_move.fixed
@@ -0,0 +1,17 @@
+// compile-flags: --edition 2024 -Zunstable-options
+// run-rustfix
+#![feature(gen_blocks)]
+
+fn moved() -> impl Iterator<Item = u32> {
+    let mut x = "foo".to_string();
+    gen move { //~ ERROR: gen block may outlive the current function
+        yield 42;
+        if x == "foo" { return }
+        x.clear();
+        for x in 3..6 { yield x }
+    }
+}
+
+fn main() {
+    for _ in moved() {}
+}
diff --git a/tests/ui/coroutine/gen_block_move.rs b/tests/ui/coroutine/gen_block_move.rs
new file mode 100644
index 00000000000..abbf8132476
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_move.rs
@@ -0,0 +1,17 @@
+// compile-flags: --edition 2024 -Zunstable-options
+// run-rustfix
+#![feature(gen_blocks)]
+
+fn moved() -> impl Iterator<Item = u32> {
+    let mut x = "foo".to_string();
+    gen { //~ ERROR: gen block may outlive the current function
+        yield 42;
+        if x == "foo" { return }
+        x.clear();
+        for x in 3..6 { yield x }
+    }
+}
+
+fn main() {
+    for _ in moved() {}
+}
diff --git a/tests/ui/coroutine/gen_block_move.stderr b/tests/ui/coroutine/gen_block_move.stderr
new file mode 100644
index 00000000000..b93ac65f5e7
--- /dev/null
+++ b/tests/ui/coroutine/gen_block_move.stderr
@@ -0,0 +1,30 @@
+error[E0373]: gen block may outlive the current function, but it borrows `x`, which is owned by the current function
+  --> $DIR/gen_block_move.rs:7:5
+   |
+LL | /     gen {
+LL | |         yield 42;
+LL | |         if x == "foo" { return }
+LL | |         x.clear();
+   | |         - `x` is borrowed here
+LL | |         for x in 3..6 { yield x }
+LL | |     }
+   | |_____^ may outlive borrowed value `x`
+   |
+note: gen block is returned here
+  --> $DIR/gen_block_move.rs:7:5
+   |
+LL | /     gen {
+LL | |         yield 42;
+LL | |         if x == "foo" { return }
+LL | |         x.clear();
+LL | |         for x in 3..6 { yield x }
+LL | |     }
+   | |_____^
+help: to force the gen block to take ownership of `x` (and any other referenced variables), use the `move` keyword
+   |
+LL |     gen move {
+   |         ++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0373`.
diff --git a/tests/ui/coroutine/gen_fn.e2024.stderr b/tests/ui/coroutine/gen_fn.e2024.stderr
new file mode 100644
index 00000000000..41bd04d9769
--- /dev/null
+++ b/tests/ui/coroutine/gen_fn.e2024.stderr
@@ -0,0 +1,10 @@
+error: `gen` blocks are not yet implemented
+  --> $DIR/gen_fn.rs:4:1
+   |
+LL | gen fn foo() {}
+   | ^^^
+   |
+   = help: only the keyword is reserved for now
+
+error: aborting due to previous error
+
diff --git a/tests/ui/coroutine/gen_fn.none.stderr b/tests/ui/coroutine/gen_fn.none.stderr
new file mode 100644
index 00000000000..5e7bd9d8bbf
--- /dev/null
+++ b/tests/ui/coroutine/gen_fn.none.stderr
@@ -0,0 +1,8 @@
+error: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found `gen`
+  --> $DIR/gen_fn.rs:4:1
+   |
+LL | gen fn foo() {}
+   | ^^^ expected one of 9 possible tokens
+
+error: aborting due to previous error
+
diff --git a/tests/ui/coroutine/gen_fn.rs b/tests/ui/coroutine/gen_fn.rs
new file mode 100644
index 00000000000..9566660dfb5
--- /dev/null
+++ b/tests/ui/coroutine/gen_fn.rs
@@ -0,0 +1,8 @@
+// revisions: e2024 none
+//[e2024] compile-flags: --edition 2024 -Zunstable-options
+
+gen fn foo() {}
+//[none]~^ ERROR: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found `gen`
+//[e2024]~^^ ERROR: `gen` blocks are not yet implemented
+
+fn main() {}
diff --git a/tests/ui/coroutine/self_referential_gen_block.rs b/tests/ui/coroutine/self_referential_gen_block.rs
new file mode 100644
index 00000000000..14daa2e9c35
--- /dev/null
+++ b/tests/ui/coroutine/self_referential_gen_block.rs
@@ -0,0 +1,17 @@
+// compile-flags: --edition 2024 -Zunstable-options
+#![feature(gen_blocks)]
+//! This test checks that we don't allow self-referential generators
+
+fn main() {
+    let mut x = {
+        let mut x = gen {
+            let y = 42;
+            let z = &y; //~ ERROR: borrow may still be in use when `gen` block yields
+            yield 43;
+            panic!("{z}");
+        };
+        x.next();
+        Box::new(x)
+    };
+    x.next();
+}
diff --git a/tests/ui/coroutine/self_referential_gen_block.stderr b/tests/ui/coroutine/self_referential_gen_block.stderr
new file mode 100644
index 00000000000..586f53df8f2
--- /dev/null
+++ b/tests/ui/coroutine/self_referential_gen_block.stderr
@@ -0,0 +1,11 @@
+error[E0626]: borrow may still be in use when `gen` block yields
+  --> $DIR/self_referential_gen_block.rs:9:21
+   |
+LL |             let z = &y;
+   |                     ^^
+LL |             yield 43;
+   |             -------- possible yield occurs here
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0626`.
diff --git a/tests/ui/feature-gates/feature-gate-coroutines.stderr b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr
index dd561643901..2e529236ad8 100644
--- a/tests/ui/feature-gates/feature-gate-coroutines.stderr
+++ b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr
@@ -1,5 +1,5 @@
 error[E0658]: yield syntax is experimental
-  --> $DIR/feature-gate-coroutines.rs:2:5
+  --> $DIR/feature-gate-coroutines.rs:5:5
    |
 LL |     yield true;
    |     ^^^^^^^^^^
@@ -8,30 +8,21 @@ LL |     yield true;
    = help: add `#![feature(coroutines)]` to the crate attributes to enable
 
 error[E0658]: yield syntax is experimental
-  --> $DIR/feature-gate-coroutines.rs:8:5
+  --> $DIR/feature-gate-coroutines.rs:9:16
    |
-LL |     yield;
-   |     ^^^^^
-   |
-   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
-   = help: add `#![feature(coroutines)]` to the crate attributes to enable
-
-error[E0658]: yield syntax is experimental
-  --> $DIR/feature-gate-coroutines.rs:9:5
-   |
-LL |     yield 0;
-   |     ^^^^^^^
+LL |     let _ = || yield true;
+   |                ^^^^^^^^^^
    |
    = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
    = help: add `#![feature(coroutines)]` to the crate attributes to enable
 
 error[E0627]: yield expression outside of coroutine literal
-  --> $DIR/feature-gate-coroutines.rs:2:5
+  --> $DIR/feature-gate-coroutines.rs:5:5
    |
 LL |     yield true;
    |     ^^^^^^^^^^
 
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
 Some errors have detailed explanations: E0627, E0658.
 For more information about an error, try `rustc --explain E0627`.
diff --git a/tests/ui/feature-gates/feature-gate-coroutines.none.stderr b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr
new file mode 100644
index 00000000000..ab24805e467
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr
@@ -0,0 +1,66 @@
+error[E0658]: yield syntax is experimental
+  --> $DIR/feature-gate-coroutines.rs:5:5
+   |
+LL |     yield true;
+   |     ^^^^^^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+
+error[E0658]: yield syntax is experimental
+  --> $DIR/feature-gate-coroutines.rs:9:16
+   |
+LL |     let _ = || yield true;
+   |                ^^^^^^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+
+error[E0658]: yield syntax is experimental
+  --> $DIR/feature-gate-coroutines.rs:16:5
+   |
+LL |     yield;
+   |     ^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+
+error[E0658]: yield syntax is experimental
+  --> $DIR/feature-gate-coroutines.rs:17:5
+   |
+LL |     yield 0;
+   |     ^^^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+
+error[E0658]: yield syntax is experimental
+  --> $DIR/feature-gate-coroutines.rs:5:5
+   |
+LL |     yield true;
+   |     ^^^^^^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error[E0658]: yield syntax is experimental
+  --> $DIR/feature-gate-coroutines.rs:9:16
+   |
+LL |     let _ = || yield true;
+   |                ^^^^^^^^^^
+   |
+   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
+   = help: add `#![feature(coroutines)]` to the crate attributes to enable
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error[E0627]: yield expression outside of coroutine literal
+  --> $DIR/feature-gate-coroutines.rs:5:5
+   |
+LL |     yield true;
+   |     ^^^^^^^^^^
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0627, E0658.
+For more information about an error, try `rustc --explain E0627`.
diff --git a/tests/ui/feature-gates/feature-gate-coroutines.rs b/tests/ui/feature-gates/feature-gate-coroutines.rs
index c3c5aec8824..53b58d486a8 100644
--- a/tests/ui/feature-gates/feature-gate-coroutines.rs
+++ b/tests/ui/feature-gates/feature-gate-coroutines.rs
@@ -1,10 +1,18 @@
+// revisions: e2024 none
+//[e2024] compile-flags: --edition 2024 -Zunstable-options
+
 fn main() {
     yield true; //~ ERROR yield syntax is experimental
                 //~^ ERROR yield expression outside of coroutine literal
+                //[none]~^^ ERROR yield syntax is experimental
+
+    let _ = || yield true; //~ ERROR yield syntax is experimental
+    //[none]~^ ERROR yield syntax is experimental
 }
 
 #[cfg(FALSE)]
 fn foo() {
-    yield; //~ ERROR yield syntax is experimental
-    yield 0; //~ ERROR yield syntax is experimental
+    // Ok in 2024 edition
+    yield; //[none]~ ERROR yield syntax is experimental
+    yield 0; //[none]~ ERROR yield syntax is experimental
 }
diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr b/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr
new file mode 100644
index 00000000000..1462c41e957
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr
@@ -0,0 +1,28 @@
+error[E0658]: gen blocks are experimental
+  --> $DIR/feature-gate-gen_blocks.rs:5:5
+   |
+LL |     gen {};
+   |     ^^^^^
+   |
+   = note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information
+   = help: add `#![feature(gen_blocks)]` to the crate attributes to enable
+
+error[E0658]: gen blocks are experimental
+  --> $DIR/feature-gate-gen_blocks.rs:13:5
+   |
+LL |     gen {};
+   |     ^^^^^
+   |
+   = note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information
+   = help: add `#![feature(gen_blocks)]` to the crate attributes to enable
+
+error[E0282]: type annotations needed
+  --> $DIR/feature-gate-gen_blocks.rs:5:9
+   |
+LL |     gen {};
+   |         ^^ cannot infer type
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0282, E0658.
+For more information about an error, try `rustc --explain E0282`.
diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr b/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr
new file mode 100644
index 00000000000..b448c35e846
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr
@@ -0,0 +1,9 @@
+error[E0422]: cannot find struct, variant or union type `gen` in this scope
+  --> $DIR/feature-gate-gen_blocks.rs:5:5
+   |
+LL |     gen {};
+   |     ^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0422`.
diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.rs b/tests/ui/feature-gates/feature-gate-gen_blocks.rs
new file mode 100644
index 00000000000..e2e1574a36a
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-gen_blocks.rs
@@ -0,0 +1,15 @@
+// revisions: e2024 none
+//[e2024] compile-flags: --edition 2024 -Zunstable-options
+
+fn main() {
+    gen {};
+    //[none]~^ ERROR: cannot find struct, variant or union type `gen`
+    //[e2024]~^^ ERROR: gen blocks are experimental
+    //[e2024]~| ERROR: type annotations needed
+}
+
+#[cfg(FALSE)]
+fn foo() {
+    gen {};
+    //[e2024]~^ ERROR: gen blocks are experimental
+}
diff --git a/tests/ui/impl-trait/bivariant-lifetime-liveness.rs b/tests/ui/impl-trait/bivariant-lifetime-liveness.rs
new file mode 100644
index 00000000000..fe99fe3f340
--- /dev/null
+++ b/tests/ui/impl-trait/bivariant-lifetime-liveness.rs
@@ -0,0 +1,15 @@
+// check-pass
+// issue: 116794
+
+// Uncaptured lifetimes should not be required to be live.
+
+struct Invariant<T>(*mut T);
+
+fn opaque<'a: 'a>(_: &'a str) -> Invariant<impl Sized> {
+    Invariant(&mut ())
+}
+
+fn main() {
+    let x = opaque(&String::new());
+    drop(x);
+}
diff --git a/tests/ui/parser/issue-116781.rs b/tests/ui/parser/issue-116781.rs
new file mode 100644
index 00000000000..0e951d2eaa4
--- /dev/null
+++ b/tests/ui/parser/issue-116781.rs
@@ -0,0 +1,8 @@
+#[derive(Debug)]
+struct Foo {
+    #[cfg(all())]
+    field: fn(($),), //~ ERROR expected pattern, found `$`
+    //~^ ERROR expected pattern, found `$`
+}
+
+fn main() {}
diff --git a/tests/ui/parser/issue-116781.stderr b/tests/ui/parser/issue-116781.stderr
new file mode 100644
index 00000000000..1a77b60a50d
--- /dev/null
+++ b/tests/ui/parser/issue-116781.stderr
@@ -0,0 +1,16 @@
+error: expected pattern, found `$`
+  --> $DIR/issue-116781.rs:4:16
+   |
+LL |     field: fn(($),),
+   |                ^ expected pattern
+
+error: expected pattern, found `$`
+  --> $DIR/issue-116781.rs:4:16
+   |
+LL |     field: fn(($),),
+   |                ^ expected pattern
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: aborting due to 2 previous errors
+