@@ -111,16 +111,11 @@ fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
111111 let data = & mut body. basic_blocks . as_mut_preserves_cfg ( ) [ bb] ;
112112 state. visit_basic_block_data ( bb, data) ;
113113 }
114- let any_replacement = state. any_replacement ;
115114
116115 // For each local that is reused (`y` above), we remove its storage statements do avoid any
117116 // difficulty. Those locals are SSA, so should be easy to optimize by LLVM without storage
118117 // statements.
119118 StorageRemover { tcx, reused_locals : state. reused_locals } . visit_body_preserves_cfg ( body) ;
120-
121- if any_replacement {
122- crate :: simplify:: remove_unused_definitions ( body) ;
123- }
124119}
125120
126121newtype_index ! {
@@ -183,7 +178,6 @@ struct VnState<'body, 'tcx> {
183178 ssa : & ' body SsaLocals ,
184179 dominators : & ' body Dominators < BasicBlock > ,
185180 reused_locals : BitSet < Local > ,
186- any_replacement : bool ,
187181}
188182
189183impl < ' body , ' tcx > VnState < ' body , ' tcx > {
@@ -205,7 +199,6 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
205199 ssa,
206200 dominators,
207201 reused_locals : BitSet :: new_empty ( local_decls. len ( ) ) ,
208- any_replacement : false ,
209202 }
210203 }
211204
@@ -305,13 +298,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
305298 {
306299 * place = local. into ( ) ;
307300 self . reused_locals . insert ( local) ;
308- self . any_replacement = true ;
309301 } else if place_ref. local != place. local
310302 || place_ref. projection . len ( ) < place. projection . len ( )
311303 {
312304 * place = place_ref. project_deeper ( & [ ] , self . tcx ) ;
313305 self . reused_locals . insert ( place_ref. local ) ;
314- self . any_replacement = true ;
315306 }
316307
317308 Some ( value)
@@ -329,7 +320,6 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
329320 let value = self . simplify_place ( place, location) ?;
330321 if let Some ( const_) = self . try_as_constant ( value) {
331322 * operand = Operand :: Constant ( Box :: new ( const_) ) ;
332- self . any_replacement = true ;
333323 }
334324 Some ( value)
335325 }
@@ -451,13 +441,11 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
451441 {
452442 if let Some ( const_) = self . try_as_constant ( value) {
453443 * rvalue = Rvalue :: Use ( Operand :: Constant ( Box :: new ( const_) ) ) ;
454- self . any_replacement = true ;
455444 } else if let Some ( local) = self . try_as_local ( value, location)
456445 && * rvalue != Rvalue :: Use ( Operand :: Move ( local. into ( ) ) )
457446 {
458447 * rvalue = Rvalue :: Use ( Operand :: Copy ( local. into ( ) ) ) ;
459448 self . reused_locals . insert ( local) ;
460- self . any_replacement = true ;
461449 }
462450 }
463451 }
0 commit comments