save some work

This commit is contained in:
T0b1
2023-04-16 14:43:18 +02:00
parent f5f984c81a
commit d9bbbcfbe2

View File

@@ -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);
}