diff options
| author | bors <bors@rust-lang.org> | 2020-12-29 06:21:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-12-29 06:21:18 +0000 |
| commit | e2a2592885539ca97bfb1232669e7519a0c0703b (patch) | |
| tree | 181d7ef79f63a7404b88557102a31f11a93be707 | |
| parent | d75f48e04d7923b44ec45fec5203a0ca749deb32 (diff) | |
| parent | 0010fc8fec235d36d9264de07dbad4508eda0a8e (diff) | |
| download | rust-e2a2592885539ca97bfb1232669e7519a0c0703b.tar.gz rust-e2a2592885539ca97bfb1232669e7519a0c0703b.zip | |
Auto merge of #79084 - simonvandel:instcombine-perf, r=oli-obk
Small perf changes for InstCombine
| -rw-r--r-- | compiler/rustc_mir/src/transform/instcombine.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/compiler/rustc_mir/src/transform/instcombine.rs b/compiler/rustc_mir/src/transform/instcombine.rs index 3eb2b500d66..990ca313c5d 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); + } } } @@ -95,7 +97,7 @@ impl<'tcx> MutVisitor<'tcx> for InstCombineVisitor<'tcx> { } } - self.super_rvalue(rvalue, location) + // We do not call super_rvalue as we are not interested in any other parts of the tree } } @@ -299,7 +301,7 @@ impl Visitor<'tcx> for OptimizationFinder<'b, 'tcx> { self.find_unneeded_equality_comparison(rvalue, location); - self.super_rvalue(rvalue, location) + // We do not call super_rvalue as we are not interested in any other parts of the tree } } @@ -310,3 +312,21 @@ 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 { + match self { + OptimizationList { + and_stars, + arrays_lengths, + unneeded_equality_comparison, + unneeded_deref, + } => { + and_stars.is_empty() + && arrays_lengths.is_empty() + && unneeded_equality_comparison.is_empty() + && unneeded_deref.is_empty() + } + } + } +} |
