From 2be7bdbc2271a5f39a8eea17e7257bc4602e8491 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Mon, 7 Jun 2021 12:27:58 -0700 Subject: [PATCH] Split-at-first-conflict: first conflict is first of (start of our range), (start of conflict range), not just the latter; otherwise we have a too-early split sometimes --- src/ion/mod.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ion/mod.rs b/src/ion/mod.rs index fd3c07b..5be5406 100644 --- a/src/ion/mod.rs +++ b/src/ion/mod.rs @@ -619,7 +619,7 @@ impl Requirement { #[derive(Clone, Debug, PartialEq, Eq)] enum AllocRegResult { Allocated(Allocation), - Conflict(LiveBundleVec), + Conflict(LiveBundleVec, ProgPoint), ConflictWithFixed(u32, ProgPoint), ConflictHighCost, } @@ -2530,6 +2530,8 @@ impl<'a, F: Function> Env<'a, F> { from_key, self.pregs[reg.index()].allocations.btree ); + let mut first_conflict: Option = None; + 'ranges: for entry in bundle_ranges { log::debug!(" -> range LR {:?}: {:?}", entry.index, entry.range); let key = LiveRangeKey::from_range(&entry.range); @@ -2606,6 +2608,13 @@ impl<'a, F: Function> Env<'a, F> { return AllocRegResult::ConflictHighCost; } } + + if first_conflict.is_none() { + first_conflict = Some(ProgPoint::from_index(std::cmp::max( + preg_key.from, + key.from, + ))); + } } else { log::debug!(" -> conflict with fixed reservation"); // range from a direct use of the PReg (due to clobber). @@ -2618,7 +2627,7 @@ impl<'a, F: Function> Env<'a, F> { } if conflicts.len() > 0 { - return AllocRegResult::Conflict(conflicts); + return AllocRegResult::Conflict(conflicts, first_conflict.unwrap()); } // We can allocate! Add our ranges to the preg's BTree. @@ -3290,11 +3299,12 @@ impl<'a, F: Function> Env<'a, F> { alloc.as_reg().unwrap(); return Ok(()); } - AllocRegResult::Conflict(bundles) => { - log::debug!(" -> conflict with bundles {:?}", bundles); - - let first_conflict_point = - self.bundles[bundles[0].index()].ranges[0].range.from; + AllocRegResult::Conflict(bundles, first_conflict_point) => { + log::debug!( + " -> conflict with bundles {:?}, first conflict at {:?}", + bundles, + first_conflict_point + ); let conflict_cost = self.maximum_spill_weight_in_bundle_set(&bundles);