@@ -29,8 +29,10 @@ impl<'tcx> MirPass<'tcx> for InstCombine {
29
29
optimization_finder. optimizations
30
30
} ;
31
31
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
+ }
34
36
}
35
37
}
36
38
@@ -95,7 +97,7 @@ impl<'tcx> MutVisitor<'tcx> for InstCombineVisitor<'tcx> {
95
97
}
96
98
}
97
99
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
99
101
}
100
102
}
101
103
@@ -299,7 +301,7 @@ impl Visitor<'tcx> for OptimizationFinder<'b, 'tcx> {
299
301
300
302
self . find_unneeded_equality_comparison ( rvalue, location) ;
301
303
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
303
305
}
304
306
}
305
307
@@ -310,3 +312,21 @@ struct OptimizationList<'tcx> {
310
312
unneeded_equality_comparison : FxHashMap < Location , Operand < ' tcx > > ,
311
313
unneeded_deref : FxHashMap < Location , Place < ' tcx > > ,
312
314
}
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