Skip to content

Commit

Permalink
JitArm64: Skip redundant imm to register writes
Browse files Browse the repository at this point in the history
When a guest register is an immediate, it may be necessary to move this
value into a register. This is handled by gpr.R(), which lacks context
on how the register will be used. This leads to cases where the
immediate is written to a register, only for it to be overwritten. Take
for example this code generated by srwx:

0x5280031b   mov    w27, #0x18
0x53187edb   lsr    w27, w22, #24

gpr.BindToRegister() does have this context through the do_load
parameter, but didn't handle immediates. By adding this logic, we can
intelligently skip the write when do_load is false.
  • Loading branch information
Bram Speeckaert committed Sep 25, 2022
1 parent 199d2be commit 9d73583
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ void Arm64GPRCache::BindToRegister(const GuestRegInfo& guest_reg, bool do_load,
m_emit->LDR(IndexType::Unsigned, host_reg, PPC_REG, u32(guest_reg.ppc_offset));
}
}
else if (reg_type == RegType::Immediate)
{
const ARM64Reg host_reg = bitsize != 64 ? GetReg() : EncodeRegTo64(GetReg());
if (do_load)
{
m_emit->MOVI2R(host_reg, reg.GetImm());
}
reg.Load(host_reg);
reg.SetDirty(set_dirty);
}
else if (set_dirty)
{
reg.SetDirty(true);
Expand Down

0 comments on commit 9d73583

Please # to comment.