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