Correct loop_headers logic.

This commit is contained in:
Camille GILLOT 2023-10-20 15:24:09 +00:00
parent 54b61d6e1a
commit 8fb99afb02
3 changed files with 4 additions and 16 deletions

View File

@ -743,7 +743,7 @@ enum Update {
/// Compute the set of loop headers in the given body. We define a loop header as a block which has
/// at least a predecessor which it dominates. This definition is only correct for reducible CFGs.
/// But if the CFG is already irreducible, there is no point in trying much harder.
/// is already irreducibl
/// is already irreducible.
fn loop_headers(body: &Body<'_>) -> BitSet<BasicBlock> {
let mut loop_headers = BitSet::new_empty(body.basic_blocks.len());
let dominators = body.basic_blocks.dominators();
@ -751,7 +751,7 @@ fn loop_headers(body: &Body<'_>) -> BitSet<BasicBlock> {
for (bb, bbdata) in traversal::preorder(body) {
for succ in bbdata.terminator().successors() {
if dominators.dominates(succ, bb) {
loop_headers.insert(bb);
loop_headers.insert(succ);
}
}
}

View File

@ -19,8 +19,7 @@
StorageLive(_1);
_1 = DFA::A;
StorageLive(_2);
- goto -> bb1;
+ goto -> bb7;
goto -> bb1;
}
bb1: {
@ -64,11 +63,6 @@
_3 = const ();
StorageDead(_7);
goto -> bb1;
+ }
+
+ bb7: {
+ _4 = discriminant(_1);
+ goto -> bb4;
}
}

View File

@ -19,8 +19,7 @@
StorageLive(_1);
_1 = DFA::A;
StorageLive(_2);
- goto -> bb1;
+ goto -> bb7;
goto -> bb1;
}
bb1: {
@ -64,11 +63,6 @@
_3 = const ();
StorageDead(_7);
goto -> bb1;
+ }
+
+ bb7: {
+ _4 = discriminant(_1);
+ goto -> bb4;
}
}