From d2bfa157dc9ed038ab298c92b52dc09fda782bb5 Mon Sep 17 00:00:00 2001 From: Sintendo <3380580+Sintendo@users.noreply.github.com> Date: Sat, 28 Dec 2024 21:53:28 +0100 Subject: [PATCH] JitArm64_Integer: addex - Optimize InHostCarry for 0 Similar to what we did for subfex, but for 0. Before: 0x5280001b mov w27, #0x0 ; =0 0x1a1f037b adc w27, w27, wzr After: 0x1a9f37fb cset w27, hs --- .../Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index eb742ac1dd..54c86ba1f1 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -1495,8 +1495,16 @@ void JitArm64::addex(UGeckoInstruction inst) { gpr.BindToRegister(d, false); ARM64Reg RD = gpr.R(d); - MOVI2R(RD, imm); - ADC(RD, RD, ARM64Reg::WZR); + if (is_zero) + { + // RD = 0 + carry = carry ? 1 : 0 + CSET(RD, CC_CS); + } + else + { + MOVI2R(RD, imm); + ADC(RD, RD, ARM64Reg::WZR); + } break; } case CarryFlag::ConstantTrue: