From d9bbbcfbe2e27413805b06eecf01eb08f55c37a4 Mon Sep 17 00:00:00 2001 From: T0b1 Date: Sun, 16 Apr 2023 14:43:18 +0200 Subject: [PATCH] save some work --- src/ion/fast_alloc.rs | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/ion/fast_alloc.rs b/src/ion/fast_alloc.rs index 1774dc2..d20aa9c 100644 --- a/src/ion/fast_alloc.rs +++ b/src/ion/fast_alloc.rs @@ -1164,27 +1164,32 @@ fn calc_live_bitmaps<'a, F: Function>( } } - for inst in insns.rev().iter() { - for pos in &[OperandPos::Late, OperandPos::Early] { - for op in state.func.inst_operands(inst) { - if op.as_fixed_nonallocatable().is_some() { - continue; + // TODO: evaluate if this generates better code than insns.rev().iter() + let last_idx = insns.last().index(); + let len = last_idx - insns.first().index() + 1; + for inst_rev_idx in 0..len { + let inst = Inst::new(last_idx - inst_rev_idx); + // TODO: this differs from the algo in liveranges.rs by not iterating through the positions + // as in SSA it should make no difference as there can be no vreg that is both a use and def at + // a single instruction + for op in state.func.inst_operands(inst) { + if op.as_fixed_nonallocatable().is_some() { + continue; + } + let was_live = live.get(op.vreg().vreg()); + trace!("op {:?} was_live = {}", op, was_live); + match op.kind() { + OperandKind::Use => { + live.set(op.vreg().vreg(), true); } - if op.pos() == *pos { - let was_live = live.get(op.vreg().vreg()); - trace!("op {:?} was_live = {}", op, was_live); - match op.kind() { - OperandKind::Use => { - live.set(op.vreg().vreg(), true); - } - OperandKind::Def => { - live.set(op.vreg().vreg(), false); - } - } + OperandKind::Def => { + live.set(op.vreg().vreg(), false); } } } } + + // TODO: i dont get why blockparams are not live when going in? for &blockparam in state.func.block_params(block) { live.set(blockparam.vreg(), false); }