@@ -29,8 +29,10 @@ impl<'tcx> MirPass<'tcx> for InstCombine {
2929 optimization_finder. optimizations
3030 } ;
3131
32- // Then carry out those optimizations.
33- MutVisitor :: visit_body ( & mut InstCombineVisitor { optimizations, tcx } , body) ;
32+ if !optimizations. is_empty ( ) {
33+ // Then carry out those optimizations.
34+ MutVisitor :: visit_body ( & mut InstCombineVisitor { optimizations, tcx } , body) ;
35+ }
3436 }
3537}
3638
@@ -95,7 +97,7 @@ impl<'tcx> MutVisitor<'tcx> for InstCombineVisitor<'tcx> {
9597 }
9698 }
9799
98- self . super_rvalue ( rvalue , location )
100+ // We do not call super_rvalue as we are not interested in any other parts of the tree
99101 }
100102}
101103
@@ -299,7 +301,7 @@ impl Visitor<'tcx> for OptimizationFinder<'b, 'tcx> {
299301
300302 self . find_unneeded_equality_comparison ( rvalue, location) ;
301303
302- self . super_rvalue ( rvalue , location )
304+ // We do not call super_rvalue as we are not interested in any other parts of the tree
303305 }
304306}
305307
@@ -310,3 +312,21 @@ struct OptimizationList<'tcx> {
310312 unneeded_equality_comparison : FxHashMap < Location , Operand < ' tcx > > ,
311313 unneeded_deref : FxHashMap < Location , Place < ' tcx > > ,
312314}
315+
316+ impl < ' tcx > OptimizationList < ' tcx > {
317+ fn is_empty ( & self ) -> bool {
318+ match self {
319+ OptimizationList {
320+ and_stars,
321+ arrays_lengths,
322+ unneeded_equality_comparison,
323+ unneeded_deref,
324+ } => {
325+ and_stars. is_empty ( )
326+ && arrays_lengths. is_empty ( )
327+ && unneeded_equality_comparison. is_empty ( )
328+ && unneeded_deref. is_empty ( )
329+ }
330+ }
331+ }
332+ }
0 commit comments