From a4ba13b4c98f668e69523448960a230c031fea37 Mon Sep 17 00:00:00 2001 From: Sintendo <3380580+Sintendo@users.noreply.github.com> Date: Sat, 28 Dec 2024 22:12:46 +0100 Subject: [PATCH] JitArm64_Integer: addex - Optimize InHostCarry for -1 Same thing we did for subfex. Before: 0x1280001a mov w26, #-0x1 ; =-1 0x1a1f035a adc w26, w26, wzr After: 0x5a9f23fa csetm w26, lo --- Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 54c86ba1f1..a6820fdfd2 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -1500,6 +1500,13 @@ void JitArm64::addex(UGeckoInstruction inst) // RD = 0 + carry = carry ? 1 : 0 CSET(RD, CC_CS); } + else if (is_all_ones) + { + // RD = -1 + carry = carry ? 0 : -1 + // Note that CSETM sets the destination to -1 if the condition is true, + // and 0 otherwise. Hence, the condition must be carry clear. + CSETM(RD, CC_CC); + } else { MOVI2R(RD, imm);