@@ -54,22 +54,6 @@ impl SimplifyCfg {
5454 let mut terminator = mem:: replace ( & mut mir. basic_block_data_mut ( bb) . terminator ,
5555 Terminator :: Diverge ) ;
5656
57- // Shortcut chains of empty blocks that just jump from one to the next
58- for target in terminator. successors_mut ( ) {
59- let new_target = match final_target ( mir, * target) {
60- Some ( new_target) => new_target,
61- None if mir. basic_block_data ( bb) . statements . is_empty ( ) => bb,
62- None => continue
63- } ;
64-
65- if * target != new_target {
66- changed = true ;
67- predecessor_map. remove_predecessor ( * target) ;
68- predecessor_map. add_predecessor ( new_target) ;
69- * target = new_target;
70- }
71- }
72-
7357 // See if we can merge the target block into this one
7458 while let Terminator :: Goto { target } = terminator {
7559 if target. index ( ) <= DIVERGE_BLOCK . index ( ) || predecessor_map. num_predecessors ( target) > 1 {
@@ -92,6 +76,22 @@ impl SimplifyCfg {
9276 terminator = other_data. terminator ;
9377 }
9478
79+ // Shortcut chains of empty blocks that just jump from one to the next
80+ for target in terminator. successors_mut ( ) {
81+ let new_target = match final_target ( mir, * target) {
82+ Some ( new_target) => new_target,
83+ None if mir. basic_block_data ( bb) . statements . is_empty ( ) => bb,
84+ None => continue
85+ } ;
86+
87+ if * target != new_target {
88+ changed = true ;
89+ predecessor_map. remove_predecessor ( * target) ;
90+ predecessor_map. add_predecessor ( new_target) ;
91+ * target = new_target;
92+ }
93+ }
94+
9595 // Restore the terminator we swapped out for Diverge
9696 mir. basic_block_data_mut ( bb) . terminator = terminator;
9797
0 commit comments