Skip to content

Commit 910cb0d

Browse files
committed
Move back edge check inside the loop
1 parent 2e106c8 commit 910cb0d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎zjit/src/hir.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6729,15 +6729,22 @@ impl Function {
67296729
for (rpo_index, &block_id) in rpo.iter().enumerate() {
67306730
let mut block_cache: HashMap<Key, InsnId> = HashMap::new();
67316731
// Set block_cache equal to the intersection of cached insns of all predecessors
6732+
// Additionally, check for back edges
67326733
match cfi.predecessors(block_id) {
67336734
[] => {},
67346735
[head] => {
67356736
block_cache = cached_insns[*head].clone();
6737+
if rpo_order[*head] > rpo_index {
6738+
has_back_edge |= true;
6739+
}
67366740
}
67376741
[head, tail @ ..] => {
67386742
block_cache = cached_insns[*head].clone();
67396743
for pred in tail {
67406744
block_cache.retain(|key, value| cached_insns[*pred].get(key) == Some(value));
6745+
if rpo_order[*head] > rpo_index {
6746+
has_back_edge |= true;
6747+
}
67416748
}
67426749
}
67436750
}
@@ -6810,13 +6817,6 @@ impl Function {
68106817

68116818
self.blocks[block_id].insns = new_insns;
68126819

6813-
// Check for back edges
6814-
for edge in self.resolve(self.blocks[block_id].terminator()).insn(self).outgoing_edges() {
6815-
if rpo_order[edge.target] <= rpo_index {
6816-
has_back_edge |= true;
6817-
}
6818-
}
6819-
68206820
if cached_insns[block_id] == block_cache {
68216821
changed = false;
68226822
}

0 commit comments

Comments
 (0)