Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't overwrite registers that we may still need to move. #1593

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -628,23 +628,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 @@ -653,8 +656,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