diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 1b020b7b462e..4e47dc24ff1a 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -741,7 +741,6 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> { } 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(_))) @@ -755,6 +754,8 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> { *rvalue = Rvalue::Use(Operand::Copy(local.into())); self.reused_locals.insert(local); } + } else { + self.super_statement(stmt, location); } } }