From e54bfd660567f6fd20e3d30b9072339ab56047b5 Mon Sep 17 00:00:00 2001 From: Sintendo <3380580+Sintendo@users.noreply.github.com> Date: Sat, 28 Dec 2024 18:12:13 +0100 Subject: [PATCH] JitArm64_Integer: Refactor subfex --- .../PowerPC/JitArm64/JitArm64_Integer.cpp | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 76f771abe5..41ad4290d0 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -1216,40 +1216,44 @@ void JitArm64::subfex(UGeckoInstruction inst) if (gpr.IsImm(a) && (mex || gpr.IsImm(b))) { - u32 i = gpr.GetImm(a), j = mex ? -1 : gpr.GetImm(b); - - gpr.BindToRegister(d, false); + const u32 i = gpr.GetImm(a); + const u32 j = mex ? -1 : gpr.GetImm(b); + const u32 imm = ~i + j; + const bool is_all_ones = imm == 0xFFFFFFFF; switch (js.carryFlag) { case CarryFlag::InPPCState: { + gpr.BindToRegister(d, false); + ARM64Reg RD = gpr.R(d); auto WA = gpr.GetScopedReg(); LDRB(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(xer_ca)); - ADDI2R(gpr.R(d), WA, ~i + j, gpr.R(d)); + ADDI2R(RD, WA, imm, RD); break; } case CarryFlag::InHostCarry: { - auto WA = gpr.GetScopedReg(); - MOVI2R(WA, ~i + j); - ADC(gpr.R(d), WA, ARM64Reg::WZR); + gpr.BindToRegister(d, false); + ARM64Reg RD = gpr.R(d); + MOVI2R(RD, imm); + ADC(RD, RD, ARM64Reg::WZR); break; } case CarryFlag::ConstantTrue: { - gpr.SetImmediate(d, ~i + j + 1); + gpr.SetImmediate(d, imm + 1); break; } case CarryFlag::ConstantFalse: { - gpr.SetImmediate(d, ~i + j); + gpr.SetImmediate(d, imm); break; } } const bool must_have_carry = Interpreter::Helper_Carry(~i, j); - const bool might_have_carry = (~i + j) == 0xFFFFFFFF; + const bool might_have_carry = is_all_ones; if (must_have_carry) {