Skip to content

Commit 0f825de

Browse files
committed
Score only fitting cache-layout blocks
Amp-Thread-ID: https://ampcode.com/threads/T-01a14c3c-fd9b-775f-8964-2600e2458079
1 parent 239c3ae commit 0f825de

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

‎crates/compiler/src/compiler/emit/targets/bytecode/layout/cache_aligned.rs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,23 +387,21 @@ impl<'a> LayoutBuilder<'a> {
387387
});
388388
let size = instr.size() as u8;
389389

390-
let scores: Vec<_> = (0..current_block)
391-
.map(|c| block_score(pred_block, c, &refs))
392-
.collect();
393390
let best = (0..current_block)
394391
.filter(|&c| self.arena.blocks[c].can_fit(size))
395-
.max_by(|&a, &b| {
396-
scores[a].partial_cmp(&scores[b]).unwrap_or_else(|| {
392+
.map(|c| (c, block_score(pred_block, c, &refs)))
393+
.max_by(|(a, score_a), (b, score_b)| {
394+
score_a.partial_cmp(score_b).unwrap_or_else(|| {
397395
panic!(
398396
"cache-aligned layout cannot compare packing scores: block {a} has \
399397
score {:?}, block {b} has score {:?}, candidate={succ_label:?}, \
400398
predecessor_block={pred_block}",
401-
scores[a], scores[b]
399+
score_a, score_b
402400
)
403401
})
404402
});
405403

406-
if let Some(candidate) = best {
404+
if let Some((candidate, _)) = best {
407405
self.arena.move_to(succ_label, candidate, size);
408406
}
409407
}

0 commit comments

Comments
 (0)