Skip to content

Commit 92186cb

Browse files
Avoid inserting into buckets if not necessary
1 parent 7379d24 commit 92186cb

File tree

1 file changed

+7
-1
lines changed
  • compiler/rustc_data_structures/src/graph/dominators

1 file changed

+7
-1
lines changed

compiler/rustc_data_structures/src/graph/dominators/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ fn dominators_given_rpo<G: ControlFlowGraph>(graph: G, rpo: &[G::Node]) -> Domin
9191
}
9292
// semi[w] is now semidominator(w).
9393

94-
bucket[semi[w]].push(w);
94+
// Optimization: Do not insert into buckets if parent[w] = semi[w], as
95+
// we then immediately know the idom.
96+
if parent[w].unwrap() != semi[w] {
97+
bucket[semi[w]].push(w);
98+
} else {
99+
idom[w] = parent[w].unwrap();
100+
}
95101

96102
// Optimization: We share the parent array between processed and not
97103
// processed elements; lastlinked represents the divider.

0 commit comments

Comments
 (0)