From 92186cb5c9228f64c7f7c832a0b61aa05e14802d Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 9 May 2021 14:06:05 -0400 Subject: Avoid inserting into buckets if not necessary --- compiler/rustc_data_structures/src/graph/dominators/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_data_structures') diff --git a/compiler/rustc_data_structures/src/graph/dominators/mod.rs b/compiler/rustc_data_structures/src/graph/dominators/mod.rs index 99119610f93..074b5a16c12 100644 --- a/compiler/rustc_data_structures/src/graph/dominators/mod.rs +++ b/compiler/rustc_data_structures/src/graph/dominators/mod.rs @@ -91,7 +91,13 @@ fn dominators_given_rpo(graph: G, rpo: &[G::Node]) -> Domin } // semi[w] is now semidominator(w). - bucket[semi[w]].push(w); + // Optimization: Do not insert into buckets if parent[w] = semi[w], as + // we then immediately know the idom. + if parent[w].unwrap() != semi[w] { + bucket[semi[w]].push(w); + } else { + idom[w] = parent[w].unwrap(); + } // Optimization: We share the parent array between processed and not // processed elements; lastlinked represents the divider. -- cgit 1.4.1-3-g733a5