@@ -476,20 +476,23 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
476476 }
477477
478478 fn visit_statement ( & mut self , stmt : & mut Statement < ' tcx > , location : Location ) {
479- self . super_statement ( stmt, location) ;
480479 if let StatementKind :: Assign ( box ( _, ref mut rvalue) ) = stmt. kind
481480 // Do not try to simplify a constant, it's already in canonical shape.
482481 && !matches ! ( rvalue, Rvalue :: Use ( Operand :: Constant ( _) ) )
483- && let Some ( value) = self . simplify_rvalue ( rvalue, location)
484482 {
485- if let Some ( const_) = self . try_as_constant ( value) {
486- * rvalue = Rvalue :: Use ( Operand :: Constant ( Box :: new ( const_) ) ) ;
487- } else if let Some ( local) = self . try_as_local ( value, location)
488- && * rvalue != Rvalue :: Use ( Operand :: Move ( local. into ( ) ) )
483+ if let Some ( value) = self . simplify_rvalue ( rvalue, location)
489484 {
490- * rvalue = Rvalue :: Use ( Operand :: Copy ( local. into ( ) ) ) ;
491- self . reused_locals . insert ( local) ;
485+ if let Some ( const_) = self . try_as_constant ( value) {
486+ * rvalue = Rvalue :: Use ( Operand :: Constant ( Box :: new ( const_) ) ) ;
487+ } else if let Some ( local) = self . try_as_local ( value, location)
488+ && * rvalue != Rvalue :: Use ( Operand :: Move ( local. into ( ) ) )
489+ {
490+ * rvalue = Rvalue :: Use ( Operand :: Copy ( local. into ( ) ) ) ;
491+ self . reused_locals . insert ( local) ;
492+ }
492493 }
494+ } else {
495+ self . super_statement ( stmt, location) ;
493496 }
494497 }
495498}
0 commit comments