From 18dd3f69f15f8659f74a7b69627db924b9d169df Mon Sep 17 00:00:00 2001 From: Sintendo <3380580+Sintendo@users.noreply.github.com> Date: Sat, 28 Dec 2024 18:15:44 +0100 Subject: [PATCH] JitArm64_Integer: subfex - Optimize InPPCState case for 0 When the immediate is zero, we can load the carry flag from memory directly to the destination register. Before: 0x394bd3b8 ldrb w24, [x29, #0x2f4] 0x2a1803f9 mov w25, w24 After: 0x394bd3b9 ldrb w25, [x29, #0x2f4] --- .../Core/PowerPC/JitArm64/JitArm64_Integer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 41ad4290d0..3b6aef8788 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -1219,6 +1219,7 @@ void JitArm64::subfex(UGeckoInstruction inst) const u32 i = gpr.GetImm(a); const u32 j = mex ? -1 : gpr.GetImm(b); const u32 imm = ~i + j; + const bool is_zero = imm == 0; const bool is_all_ones = imm == 0xFFFFFFFF; switch (js.carryFlag) @@ -1227,9 +1228,16 @@ void JitArm64::subfex(UGeckoInstruction inst) { gpr.BindToRegister(d, false); ARM64Reg RD = gpr.R(d); - auto WA = gpr.GetScopedReg(); - LDRB(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(xer_ca)); - ADDI2R(RD, WA, imm, RD); + if (is_zero) + { + LDRB(IndexType::Unsigned, RD, PPC_REG, PPCSTATE_OFF(xer_ca)); + } + else + { + auto WA = gpr.GetScopedReg(); + LDRB(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(xer_ca)); + ADDI2R(RD, WA, imm, RD); + } break; } case CarryFlag::InHostCarry: