Skip to content

Commit

Permalink
Merge pull request #1593 from ltratt/dont_buckle_under_pressure
Browse files Browse the repository at this point in the history
Don't overwrite registers that we may still need to move.
  • Loading branch information
vext01 authored Feb 10, 2025
2 parents c3537dd + d4a154f commit 806507c
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions ykrt/src/compile/jitc_yk/codegen/x64/lsregalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,23 +660,26 @@ impl LSRegAlloc<'_> {
&GPConstraint::Input { op: rhs_op, .. }
| &GPConstraint::InputOutput { op: rhs_op, .. },
) => {
if lhs_op == rhs_op {
changed = true;
self.copy_gp_reg(asm, old_reg, reg);
} else {
if let RegState::Empty =
self.gp_reg_states[usize::from(reg.code())]
{
if let RegState::Empty =
self.gp_reg_states[usize::from(reg.code())]
{
if lhs_op == rhs_op {
self.copy_gp_reg(asm, old_reg, reg);
} else {
self.move_gp_reg(asm, old_reg, reg);
} else if let RegState::Empty =
self.gp_reg_states[usize::from(old_reg.code())]
{
self.move_gp_reg(asm, reg, old_reg);
}
} else if let RegState::Empty =
self.gp_reg_states[usize::from(old_reg.code())]
{
if lhs_op == rhs_op {
self.copy_gp_reg(asm, reg, old_reg);
} else {
self.swap_gp_reg(asm, reg, old_reg);
self.move_gp_reg(asm, reg, old_reg);
}
changed = true;
} else {
self.swap_gp_reg(asm, reg, old_reg);
}
changed = true;
}
(
&GPConstraint::Input { .. }
Expand All @@ -685,8 +688,18 @@ impl LSRegAlloc<'_> {
| GPConstraint::Clobber { .. }
| GPConstraint::Temporary,
) => {
if let RegState::Empty =
self.gp_reg_states[usize::from(reg.code())]
{
self.move_gp_reg(asm, old_reg, reg);
} else if let RegState::Empty =
self.gp_reg_states[usize::from(old_reg.code())]
{
self.move_gp_reg(asm, reg, old_reg);
} else {
self.swap_gp_reg(asm, reg, old_reg);
}
changed = true;
self.move_gp_reg(asm, old_reg, reg);
}
_ => (),
}
Expand Down

0 comments on commit 806507c

Please sign in to comment.