Commit 49c9eafb authored by qinsoon's avatar qinsoon

add a freeze heuristics that prioritize freezing less frequenly used

nodes
parent 1dbd1d9b
Pipeline #1250 passed with stages
in 50 minutes and 41 seconds
......@@ -835,14 +835,40 @@ impl<'a> GraphColoring<'a> {
fn freeze(&mut self) {
// it is not empty (checked before)
let node = self.worklist_freeze.pop_front().unwrap();
let node = self.freeze_heuristics();
trace!("Freezing {}...", node);
trace!(" insert {} to worklistSimplify", node);
trace!(" move {} from worklistFreeze to worklistSimplify", node);
self.worklist_freeze.remove(&node);
self.worklist_simplify.insert(node);
self.freeze_moves(node);
}
fn freeze_heuristics(&mut self) -> MuID {
use std::f32;
// we try to freeze a node that appears less frequently
// we compute freeze cost based on all the moves related with this node
let mut candidate = None;
let mut candidate_cost = f32::MAX;
for &n in self.worklist_freeze.iter() {
// freeze_cost(n) = SUM ((spill_cost(src) + spill_cost(dst)) for m (mov src->dst)
// in movelist[n])
let mut freeze_cost = 0f32;
for m in self.get_movelist(n).iter() {
freeze_cost += self.ig.get_spill_cost(m.from);
freeze_cost += self.ig.get_spill_cost(m.to);
}
if freeze_cost < candidate_cost {
candidate = Some(n);
candidate_cost = freeze_cost;
}
}
assert!(candidate.is_some());
candidate.unwrap()
}
fn freeze_moves(&mut self, u: MuID) {
trace!(" freeze moves for {}", u);
for m in self.node_moves(u).iter() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment