@@ -54,22 +54,6 @@ impl SimplifyCfg {
54
54
let mut terminator = mem:: replace ( & mut mir. basic_block_data_mut ( bb) . terminator ,
55
55
Terminator :: Diverge ) ;
56
56
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
-
73
57
// See if we can merge the target block into this one
74
58
while let Terminator :: Goto { target } = terminator {
75
59
if target. index ( ) <= DIVERGE_BLOCK . index ( ) || predecessor_map. num_predecessors ( target) > 1 {
@@ -92,6 +76,22 @@ impl SimplifyCfg {
92
76
terminator = other_data. terminator ;
93
77
}
94
78
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
+
95
95
// Restore the terminator we swapped out for Diverge
96
96
mir. basic_block_data_mut ( bb) . terminator = terminator;
97
97
0 commit comments