about summary refs log tree commit diff
path: root/compiler/rustc_index/src/interval.rs
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2025-07-02 08:36:22 +0000
committerCamille Gillot <gillot.camille@gmail.com>2025-09-07 16:24:46 +0000
commit9b8a719ae48db491a5f18d52fdbb802508bf75a5 (patch)
tree1bf9470fee0c7b0563924990a158e24a2e47995e /compiler/rustc_index/src/interval.rs
parent2ff92e83af6d646e05218374954c6ed2ebb67b3d (diff)
downloadrust-9b8a719ae48db491a5f18d52fdbb802508bf75a5.tar.gz
rust-9b8a719ae48db491a5f18d52fdbb802508bf75a5.zip
Reimplement DestinationPropagation according to live ranges.
Diffstat (limited to 'compiler/rustc_index/src/interval.rs')
-rw-r--r--compiler/rustc_index/src/interval.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/compiler/rustc_index/src/interval.rs b/compiler/rustc_index/src/interval.rs
index 4af5bfcaee6..69a7a69610e 100644
--- a/compiler/rustc_index/src/interval.rs
+++ b/compiler/rustc_index/src/interval.rs
@@ -219,6 +219,32 @@ impl<I: Idx> IntervalSet<I> {
         })
     }
 
+    pub fn disjoint(&self, other: &IntervalSet<I>) -> bool
+    where
+        I: Step,
+    {
+        let helper = move || {
+            let mut self_iter = self.iter_intervals();
+            let mut other_iter = other.iter_intervals();
+
+            let mut self_current = self_iter.next()?;
+            let mut other_current = other_iter.next()?;
+
+            loop {
+                if self_current.end <= other_current.start {
+                    self_current = self_iter.next()?;
+                    continue;
+                }
+                if other_current.end <= self_current.start {
+                    other_current = other_iter.next()?;
+                    continue;
+                }
+                return Some(false);
+            }
+        };
+        helper().unwrap_or(true)
+    }
+
     pub fn is_empty(&self) -> bool {
         self.map.is_empty()
     }