From fac842021c24379e13a0407483e7c67b2607566c Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 17 Jun 2021 15:30:17 +0200 Subject: [PATCH] JitArm64: Use SBC/SBCS for emulating subfex SBC/SBCS does the same thing as subfex, except with the source operands in the opposite order. --- .../Core/PowerPC/JitArm64/JitArm64_Integer.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 568a3e0eeb..c92eeb9f84 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -994,7 +994,6 @@ void JitArm64::subfex(UGeckoInstruction inst) } else { - ARM64Reg WA = js.carryFlag != CarryFlag::ConstantTrue ? gpr.GetReg() : ARM64Reg::INVALID_REG; gpr.BindToRegister(d, d == a || d == b); switch (js.carryFlag) @@ -1002,18 +1001,15 @@ void JitArm64::subfex(UGeckoInstruction inst) case CarryFlag::InPPCState: { // upload the carry state + ARM64Reg WA = gpr.GetReg(); LDRB(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(xer_ca)); CMP(WA, 1); + gpr.Unlock(WA); [[fallthrough]]; } case CarryFlag::InHostCarry: { - if (gpr.IsImm(a)) - MOVI2R(WA, u32(~gpr.GetImm(a))); - else - MVN(WA, gpr.R(a)); - - CARRY_IF_NEEDED(ADC, ADCS, gpr.R(d), WA, gpr.R(b)); + CARRY_IF_NEEDED(SBC, SBCS, gpr.R(d), gpr.R(b), gpr.R(a)); ComputeCarry(); break; } @@ -1025,19 +1021,20 @@ void JitArm64::subfex(UGeckoInstruction inst) } case CarryFlag::ConstantFalse: { + ARM64Reg WA = gpr.GetReg(); + if (gpr.IsImm(a)) MOVI2R(WA, u32(~gpr.GetImm(a))); else MVN(WA, gpr.R(a)); CARRY_IF_NEEDED(ADD, ADDS, gpr.R(d), WA, gpr.R(b)); + + gpr.Unlock(WA); ComputeCarry(); break; } } - - if (WA != ARM64Reg::INVALID_REG) - gpr.Unlock(WA); } if (inst.Rc)