From 8984777749b6053da703b5e219fe9a8f0e577fd2 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 1 Oct 2022 20:28:39 +0200 Subject: [PATCH] JitArm64: Call GetImm before BindToRegister In case the register we're binding is the same as the immediate register, we should fetch the immediate before calling BindToRegister. The way the register cache currently works, calling GetImm after BindToRegister actually does work, but it's better to not rely on it. --- Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 7222a361cd..2fc1524809 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -476,9 +476,11 @@ void JitArm64::addx(UGeckoInstruction inst) { int imm_reg = gpr.IsImm(a) ? a : b; int in_reg = gpr.IsImm(a) ? b : a; + int imm_value = gpr.GetImm(imm_reg); + gpr.BindToRegister(d, d == in_reg); ARM64Reg WA = gpr.GetReg(); - ADDI2R(gpr.R(d), gpr.R(in_reg), gpr.GetImm(imm_reg), WA); + ADDI2R(gpr.R(d), gpr.R(in_reg), imm_value, WA); gpr.Unlock(WA); if (inst.Rc) ComputeRC0(gpr.R(d)); @@ -745,11 +747,11 @@ void JitArm64::rlwnmx(UGeckoInstruction inst) } else if (gpr.IsImm(b)) { + int imm_value = gpr.GetImm(b) & 0x1f; gpr.BindToRegister(a, a == s); ARM64Reg WA = gpr.GetReg(); - ArithOption Shift(gpr.R(s), ShiftType::ROR, 32 - (gpr.GetImm(b) & 0x1f)); MOVI2R(WA, mask); - AND(gpr.R(a), WA, gpr.R(s), Shift); + AND(gpr.R(a), WA, gpr.R(s), ArithOption(gpr.R(s), ShiftType::ROR, 32 - imm_value)); gpr.Unlock(WA); if (inst.Rc) ComputeRC0(gpr.R(a));