Skip to content
Snippets Groups Projects
Commit 29e1a477 authored by rarbore2's avatar rarbore2
Browse files

Merge branch 'dom_fix' into 'main'

Fix LCA calculation in dom tree

See merge request llvm/hercules!54
parents 62b32318 6fed1b7d
No related branches found
No related tags found
1 merge request!54Fix LCA calculation in dom tree
Pipeline #200272 passed
...@@ -82,6 +82,9 @@ impl DomTree { ...@@ -82,6 +82,9 @@ impl DomTree {
* ancestor of the two nodes that is as far down the tree as possible. * ancestor of the two nodes that is as far down the tree as possible.
*/ */
pub fn least_common_ancestor(&self, mut a: NodeID, mut b: NodeID) -> NodeID { pub fn least_common_ancestor(&self, mut a: NodeID, mut b: NodeID) -> NodeID {
if a == self.root || b == self.root {
return self.root;
}
while self.idom[&a].0 > self.idom[&b].0 { while self.idom[&a].0 > self.idom[&b].0 {
a = self.idom[&a].1; a = self.idom[&a].1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment