Rollup merge of #65648 - nnethercote:rm-intersect_opt, r=nikomatsakis
Eliminate `intersect_opt`. Its fourth argument is always `Some(pred)`, so the pattern matching is unnecessary. This commit inlines and removes it. r? @nikomatsakis
This commit is contained in:
commit
951b8c84be
@ -17,7 +17,7 @@ pub fn dominators<G: ControlFlowGraph>(graph: &G) -> Dominators<G::Node> {
|
|||||||
dominators_given_rpo(graph, &rpo)
|
dominators_given_rpo(graph, &rpo)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dominators_given_rpo<G: ControlFlowGraph>(
|
fn dominators_given_rpo<G: ControlFlowGraph>(
|
||||||
graph: &G,
|
graph: &G,
|
||||||
rpo: &[G::Node],
|
rpo: &[G::Node],
|
||||||
) -> Dominators<G::Node> {
|
) -> Dominators<G::Node> {
|
||||||
@ -43,14 +43,12 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(
|
|||||||
let mut new_idom = None;
|
let mut new_idom = None;
|
||||||
for pred in graph.predecessors(node) {
|
for pred in graph.predecessors(node) {
|
||||||
if immediate_dominators[pred].is_some() {
|
if immediate_dominators[pred].is_some() {
|
||||||
// (*)
|
|
||||||
// (*) dominators for `pred` have been calculated
|
// (*) dominators for `pred` have been calculated
|
||||||
new_idom = intersect_opt(
|
new_idom = Some(if let Some(new_idom) = new_idom {
|
||||||
&post_order_rank,
|
intersect(&post_order_rank, &immediate_dominators, new_idom, pred)
|
||||||
&immediate_dominators,
|
} else {
|
||||||
new_idom,
|
pred
|
||||||
Some(pred),
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,19 +65,6 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intersect_opt<Node: Idx>(
|
|
||||||
post_order_rank: &IndexVec<Node, usize>,
|
|
||||||
immediate_dominators: &IndexVec<Node, Option<Node>>,
|
|
||||||
node1: Option<Node>,
|
|
||||||
node2: Option<Node>,
|
|
||||||
) -> Option<Node> {
|
|
||||||
match (node1, node2) {
|
|
||||||
(None, None) => None,
|
|
||||||
(Some(n), None) | (None, Some(n)) => Some(n),
|
|
||||||
(Some(n1), Some(n2)) => Some(intersect(post_order_rank, immediate_dominators, n1, n2)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn intersect<Node: Idx>(
|
fn intersect<Node: Idx>(
|
||||||
post_order_rank: &IndexVec<Node, usize>,
|
post_order_rank: &IndexVec<Node, usize>,
|
||||||
immediate_dominators: &IndexVec<Node, Option<Node>>,
|
immediate_dominators: &IndexVec<Node, Option<Node>>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user