From d8c78f2a922623aa03875bd496113bc42622e34d Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 21 Dec 2023 20:51:32 +0100 Subject: [PATCH] JitArm64: Fix the "do nothing" cases of ANDI2R and friends So somehow I forgot that AArch64 uses three-operand encoding... Fixes a regression from 6303416201 which manifested in various ways, such as incorrect rendering of the Wind Waker title screen. --- Source/Core/Common/Arm64Emitter.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/Core/Common/Arm64Emitter.cpp b/Source/Core/Common/Arm64Emitter.cpp index 6f4f42c027..4dd39c4357 100644 --- a/Source/Core/Common/Arm64Emitter.cpp +++ b/Source/Core/Common/Arm64Emitter.cpp @@ -4051,14 +4051,15 @@ void ARM64XEmitter::ANDI2R(ARM64Reg Rd, ARM64Reg Rn, u64 imm, ARM64Reg scratch) imm = (imm << 32) | (imm & 0xFFFFFFFF); } - if ((~imm) == 0) - { - // Do nothing - } - else if (imm == 0) + if (imm == 0) { MOVZ(Rd, 0); } + else if ((~imm) == 0) + { + if (Rd != Rn) + MOV(Rd, Rn); + } else if (const auto result = LogicalImm(imm, GPRSize::B64)) { AND(Rd, Rn, result); @@ -4090,7 +4091,8 @@ void ARM64XEmitter::ORRI2R(ARM64Reg Rd, ARM64Reg Rn, u64 imm, ARM64Reg scratch) if (imm == 0) { - // Do nothing + if (Rd != Rn) + MOV(Rd, Rn); } else if ((~imm) == 0) { @@ -4127,7 +4129,8 @@ void ARM64XEmitter::EORI2R(ARM64Reg Rd, ARM64Reg Rn, u64 imm, ARM64Reg scratch) if (imm == 0) { - // Do nothing + if (Rd != Rn) + MOV(Rd, Rn); } else if ((~imm) == 0) {