@@ -483,20 +483,23 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
483483 }
484484
485485 fn visit_statement ( & mut self , stmt : & mut Statement < ' tcx > , location : Location ) {
486- self . super_statement ( stmt, location) ;
487486 if let StatementKind :: Assign ( box ( _, ref mut rvalue) ) = stmt. kind
488487 // Do not try to simplify a constant, it's already in canonical shape.
489488 && !matches ! ( rvalue, Rvalue :: Use ( Operand :: Constant ( _) ) )
490- && let Some ( value) = self . simplify_rvalue ( rvalue, location)
491489 {
492- if let Some ( const_) = self . try_as_constant ( value) {
493- * rvalue = Rvalue :: Use ( Operand :: Constant ( Box :: new ( const_) ) ) ;
494- } else if let Some ( local) = self . try_as_local ( value, location)
495- && * rvalue != Rvalue :: Use ( Operand :: Move ( local. into ( ) ) )
490+ if let Some ( value) = self . simplify_rvalue ( rvalue, location)
496491 {
497- * rvalue = Rvalue :: Use ( Operand :: Copy ( local. into ( ) ) ) ;
498- self . reused_locals . insert ( local) ;
492+ if let Some ( const_) = self . try_as_constant ( value) {
493+ * rvalue = Rvalue :: Use ( Operand :: Constant ( Box :: new ( const_) ) ) ;
494+ } else if let Some ( local) = self . try_as_local ( value, location)
495+ && * rvalue != Rvalue :: Use ( Operand :: Move ( local. into ( ) ) )
496+ {
497+ * rvalue = Rvalue :: Use ( Operand :: Copy ( local. into ( ) ) ) ;
498+ self . reused_locals . insert ( local) ;
499+ }
499500 }
501+ } else {
502+ self . super_statement ( stmt, location) ;
500503 }
501504 }
502505}
0 commit comments