Correct loop_headers logic.
This commit is contained in:
parent
54b61d6e1a
commit
8fb99afb02
@ -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
|
/// 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.
|
/// 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.
|
/// 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> {
|
fn loop_headers(body: &Body<'_>) -> BitSet<BasicBlock> {
|
||||||
let mut loop_headers = BitSet::new_empty(body.basic_blocks.len());
|
let mut loop_headers = BitSet::new_empty(body.basic_blocks.len());
|
||||||
let dominators = body.basic_blocks.dominators();
|
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 (bb, bbdata) in traversal::preorder(body) {
|
||||||
for succ in bbdata.terminator().successors() {
|
for succ in bbdata.terminator().successors() {
|
||||||
if dominators.dominates(succ, bb) {
|
if dominators.dominates(succ, bb) {
|
||||||
loop_headers.insert(bb);
|
loop_headers.insert(succ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
StorageLive(_1);
|
StorageLive(_1);
|
||||||
_1 = DFA::A;
|
_1 = DFA::A;
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
- goto -> bb1;
|
goto -> bb1;
|
||||||
+ goto -> bb7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb1: {
|
bb1: {
|
||||||
@ -64,11 +63,6 @@
|
|||||||
_3 = const ();
|
_3 = const ();
|
||||||
StorageDead(_7);
|
StorageDead(_7);
|
||||||
goto -> bb1;
|
goto -> bb1;
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ bb7: {
|
|
||||||
+ _4 = discriminant(_1);
|
|
||||||
+ goto -> bb4;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
StorageLive(_1);
|
StorageLive(_1);
|
||||||
_1 = DFA::A;
|
_1 = DFA::A;
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
- goto -> bb1;
|
goto -> bb1;
|
||||||
+ goto -> bb7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb1: {
|
bb1: {
|
||||||
@ -64,11 +63,6 @@
|
|||||||
_3 = const ();
|
_3 = const ();
|
||||||
StorageDead(_7);
|
StorageDead(_7);
|
||||||
goto -> bb1;
|
goto -> bb1;
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ bb7: {
|
|
||||||
+ _4 = discriminant(_1);
|
|
||||||
+ goto -> bb4;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user