Only go through the body if something can be optimized
This commit is contained in:
@@ -29,9 +29,11 @@ impl<'tcx> MirPass<'tcx> for InstCombine {
|
|||||||
optimization_finder.optimizations
|
optimization_finder.optimizations
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if !optimizations.is_empty() {
|
||||||
// Then carry out those optimizations.
|
// Then carry out those optimizations.
|
||||||
MutVisitor::visit_body(&mut InstCombineVisitor { optimizations, tcx }, body);
|
MutVisitor::visit_body(&mut InstCombineVisitor { optimizations, tcx }, body);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InstCombineVisitor<'tcx> {
|
pub struct InstCombineVisitor<'tcx> {
|
||||||
@@ -296,3 +298,12 @@ struct OptimizationList<'tcx> {
|
|||||||
unneeded_equality_comparison: FxHashMap<Location, Operand<'tcx>>,
|
unneeded_equality_comparison: FxHashMap<Location, Operand<'tcx>>,
|
||||||
unneeded_deref: FxHashMap<Location, Place<'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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user