From f7fa22a05387c5b59be1e3c8424065193a064161 Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 13 Aug 2015 13:35:44 +0200 Subject: [PATCH 1/2] JitArm64: fix addzex CMP don't update the carry flag, so we have to use an addition. --- Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index dd367d17f1..5d3fece552 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -678,17 +678,12 @@ void JitArm64::addzex(UGeckoInstruction inst) JITDISABLE(bJITIntegerOff); FALLBACK_IF(inst.OE); - // breaks Kirby - FALLBACK_IF(1); - int a = inst.RA, d = inst.RD; gpr.BindToRegister(d, d == a); ARM64Reg WA = gpr.GetReg(); LDRB(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(xer_ca)); - CMP(WA, 0); - CSINC(gpr.R(d), gpr.R(a), gpr.R(a), CC_EQ); - CMP(gpr.R(d), 0); + ADDS(gpr.R(d), gpr.R(a), WA); gpr.Unlock(WA); ComputeCarry(); if (inst.Rc) From 4ef29620558c2cf5c5aab0ca3929eee38a1c57fd Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 13 Aug 2015 13:40:17 +0200 Subject: [PATCH 2/2] JitArm64: optimize addzex So on the general case, we don't need a tempory register. --- .../PowerPC/JitArm64/JitArm64_Integer.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 5d3fece552..1ae60dc0b8 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -680,11 +680,21 @@ void JitArm64::addzex(UGeckoInstruction inst) int a = inst.RA, d = inst.RD; - gpr.BindToRegister(d, d == a); - ARM64Reg WA = gpr.GetReg(); - LDRB(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(xer_ca)); - ADDS(gpr.R(d), gpr.R(a), WA); - gpr.Unlock(WA); + if (d == a) + { + gpr.BindToRegister(d, true); + ARM64Reg WA = gpr.GetReg(); + LDRB(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(xer_ca)); + ADDS(gpr.R(d), gpr.R(a), WA); + gpr.Unlock(WA); + } + else + { + gpr.BindToRegister(d, false); + LDRB(INDEX_UNSIGNED, gpr.R(d), X29, PPCSTATE_OFF(xer_ca)); + ADDS(gpr.R(d), gpr.R(a), gpr.R(d)); + } + ComputeCarry(); if (inst.Rc) ComputeRC(gpr.R(d), 0);