diff --git a/src/mir.rs b/src/mir.rs index 8e06108..42b080d 100644 --- a/src/mir.rs +++ b/src/mir.rs @@ -1306,11 +1306,17 @@ pub mod liveness { }); let mut edges = HashSet::<(u32, u32)>::new(); + // eprint!("intervals: ["); for (from, to) in intervals { - for &(other, _) in references.range(from.exclusive_start()..to.inclusive_end()) { + // eprint!("({from})..({to}), "); + if !mir.is_register(from.0) { + continue; + } + for &(other, _) in references.range(from.exclusive_start()..to.exclusive_end()) { edges.insert((from.0, other.0)); } } + // eprintln!("]"); let inference_graph = petgraph::graph::UnGraph::<(), ()>::from_edges(edges.into_iter()); @@ -1614,6 +1620,7 @@ pub mod liveness { } impl Mir { + /// returns the in/out operand, if it exists: example would be (%node = add rax, rcx) -> rax fn dst_node(&self, node: NodeRef) -> Option { // for each node, look at the dst node and see if it has preferred // color, then also prefer that color. @@ -2463,7 +2470,7 @@ impl Mir { let rhs = self.node_as_operand(&liveness, &mapping, &mut func, strings, rhs); writeln!(func.current_branch(), "mulss {lhs}, {rhs}")?; - if lhs.occupy_same_register(dst) { + if !lhs.occupy_same_register(dst) { writeln!(func.current_branch(), "movss {dst}, {lhs}")?; } } @@ -2474,7 +2481,7 @@ impl Mir { let rhs = self.node_as_operand(&liveness, &mapping, &mut func, strings, rhs); writeln!(func.current_branch(), "divss {lhs}, {rhs}")?; - if lhs.occupy_same_register(dst) { + if !lhs.occupy_same_register(dst) { writeln!(func.current_branch(), "movss {dst}, {lhs}")?; } }