Only go through the body if something can be optimized
This commit is contained in:
parent
307c60843c
commit
3d5a1e330f
1 changed files with 13 additions and 2 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue