Skip to content

Commit

Permalink
boots: Try to speed-up initializeRegisters
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Oct 22, 2024
1 parent 22c6479 commit 33b6507
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions pkgs/boots/regalloc.dora
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl SimpleRegisterAllocator {
} else if predecessorCount == 0 {
// Do nothing.
} else {
let candidates = HashMap[Inst, Int64]::new();
let candidates = HashMap[Inst, Int]::new();
let mut idx = 0;

for predecessorEdge in block.predecessors {
Expand Down Expand Up @@ -130,14 +130,22 @@ impl SimpleRegisterAllocator {
continue;
}

let current = candidates.get(inst);
let current = if current is Some(current) {
current + 1
} else {
1
};
if current == predecessorCount {
assert(registers.allocateFixedRegister(reg, inst));
let count = candidates.get(inst).unwrapOr(0);

if idx == 0 || count > 0 {
if idx + 1 == predecessorCount {
if idx == count {
assert(registers.allocateFixedRegister(reg, inst));
}
} else if idx == 0 {
assert(candidates.insert(inst, 1).isNone());
} else {
if idx == count {
candidates.insert(inst, count + 1);
} else {
candidates.remove(inst);
}
}
}
}
}
Expand Down

0 comments on commit 33b6507

Please sign in to comment.