Skip to content

Commit

Permalink
Do not visit rvalues twice.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Sep 23, 2023
1 parent 87104ba commit ce2e3e0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_mir_transform/src/gvn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)))
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit ce2e3e0

Please sign in to comment.