Skip to content

Commit

Permalink
Optimise spillage by removing future_spilling() (#152)
Browse files Browse the repository at this point in the history
This prevents "future" or positive spillage from being reported as
spillage. In essence, this feature is removed completely.
  • Loading branch information
DavePearce authored May 20, 2024
1 parent e1ad459 commit 067b412
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/compiler/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ impl ConstraintSet {
.filter_map(|c| match c {
Computation::Composite { target, exp } => {
if target.as_handle().module == m {
Some(exp.past_spill().abs().max(exp.future_spill().abs()))
Some(exp.past_spill().abs())
} else {
None
}
Expand All @@ -862,7 +862,7 @@ impl ConstraintSet {
.chain(self.constraints.iter().filter_map(|c| match c {
Constraint::Vanishes { handle, expr, .. } => {
if handle.module == m {
Some(expr.past_spill().abs().max(expr.future_spill().abs()))
Some(expr.past_spill().abs())
} else {
None
}
Expand Down
17 changes: 0 additions & 17 deletions src/compiler/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,23 +498,6 @@ impl Node {
.unwrap_or(0)
}

/// Compute the maximum future (positive) shift coefficient in the AST rooted at `self`
pub fn future_spill(&self) -> isize {
self.leaves()
.iter()
.filter_map(|n| match n.e() {
Expression::Column { shift, .. } | Expression::ExoColumn { shift, .. } => {
Some(*shift as isize)
}
Expression::ArrayColumn { .. } => unreachable!(),
_ => None,
})
.filter(|x| *x > 0)
.max()
.unwrap_or(0)
.max(0)
}

// TODO: replace with a generic map()
pub fn add_id_to_handles(&mut self, set_id: &dyn Fn(&mut ColumnRef)) {
match self.e_mut() {
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ fn render_spilling_toml(cs: &ConstraintSet) {
// Convert name to screaming snake case.
let name = module.to_case(Case::UpperSnake);
//
println!("{:>10} = {:>4}", name.blue().bold(), spilling);
println!("{:>10} = {:>4}", name, spilling);
}
}

Expand Down

0 comments on commit 067b412

Please sign in to comment.