diff --git a/src/ion/dump.rs b/src/ion/dump.rs index c291253..bb1729b 100644 --- a/src/ion/dump.rs +++ b/src/ion/dump.rs @@ -1,7 +1,7 @@ //! Debugging output. use super::Env; -use crate::{Function, ProgPoint, Block}; +use crate::{Block, Function, ProgPoint}; impl<'a, F: Function> Env<'a, F> { pub fn dump_state(&self) { diff --git a/src/ion/liveranges.rs b/src/ion/liveranges.rs index 04ca41e..231920d 100644 --- a/src/ion/liveranges.rs +++ b/src/ion/liveranges.rs @@ -32,7 +32,9 @@ use std::convert::TryFrom; pub fn spill_weight_from_policy(policy: OperandPolicy, loop_depth: usize, is_def: bool) -> u32 { // A bonus of 1000 for one loop level, 4000 for two loop levels, // 16000 for three loop levels, etc. Avoids exponentiation. - let hot_bonus = std::cmp::min(16000, 1000 * (1 << (2 * loop_depth))); + // Bound `loop_depth` at 2 so that `hot_bonus` is at most 16000. + let loop_depth = std::cmp::min(2, loop_depth); + let hot_bonus = 1000 * (1 << (2 * loop_depth)); let def_bonus = if is_def { 2000 } else { 0 }; let policy_bonus = match policy { OperandPolicy::Any => 1000,