diff options
| author | Simon Vandel Sillesen <simon.vandel@gmail.com> | 2020-11-15 22:34:50 +0100 |
|---|---|---|
| committer | Simon Vandel Sillesen <simon.vandel@gmail.com> | 2020-11-15 22:34:54 +0100 |
| commit | 3d5a1e330fb48c5f64b078cf755cbb44ee73343e (patch) | |
| tree | add40fb0fb1c897feefe05e140172e78bed6f9c8 | |
| parent | 307c60843ce853cf6883f5330e71cde35838d78b (diff) | |
| download | rust-3d5a1e330fb48c5f64b078cf755cbb44ee73343e.tar.gz rust-3d5a1e330fb48c5f64b078cf755cbb44ee73343e.zip | |
Only go through the body if something can be optimized
| -rw-r--r-- | compiler/rustc_mir/src/transform/instcombine.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/compiler/rustc_mir/src/transform/instcombine.rs b/compiler/rustc_mir/src/transform/instcombine.rs index b36633fbfb3..04ea2bb542e 100644 --- a/compiler/rustc_mir/src/transform/instcombine.rs +++ b/compiler/rustc_mir/src/transform/instcombine.rs @@ -29,8 +29,10 @@ impl<'tcx> MirPass<'tcx> for InstCombine { optimization_finder.optimizations }; - // Then carry out those optimizations. - MutVisitor::visit_body(&mut InstCombineVisitor { optimizations, tcx }, body); + if !optimizations.is_empty() { + // Then carry out those optimizations. + MutVisitor::visit_body(&mut InstCombineVisitor { optimizations, tcx }, body); + } } } @@ -296,3 +298,12 @@ struct OptimizationList<'tcx> { unneeded_equality_comparison: FxHashMap<Location, Operand<'tcx>>, unneeded_deref: FxHashMap<Location, Place<'tcx>>, } + +impl<'tcx> OptimizationList<'tcx> { + fn is_empty(&self) -> bool { + self.and_stars.is_empty() + && self.arrays_lengths.is_empty() + && self.unneeded_equality_comparison.is_empty() + && self.unneeded_deref.is_empty() + } +} |
