diff --git a/hercules_ir/src/dom.rs b/hercules_ir/src/dom.rs
index 7c4bb8a2779100e5bbf4f43b54a67b2fabe32de1..9708e3b2e44aaae93a9704093d58c60aafa85203 100644
--- a/hercules_ir/src/dom.rs
+++ b/hercules_ir/src/dom.rs
@@ -82,10 +82,10 @@ impl DomTree {
      * 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 {
-        while self.idom[&a].0 < self.idom[&b].0 {
+        while self.idom[&a].0 > self.idom[&b].0 {
             a = self.idom[&a].1;
         }
-        while self.idom[&a].0 > self.idom[&b].0 {
+        while self.idom[&a].0 < self.idom[&b].0 {
             b = self.idom[&b].1;
         }
         while a != b {