From b59c0d0b45db3d98f4627891666bb53867014919 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 29 Dec 2017 12:46:09 -0800 Subject: [PATCH] arm64jit: Use CMN for CMPI2R if possible. It's not hit all that often, but it is hit. --- Common/Arm64Emitter.cpp | 8 ++++++++ Common/Arm64Emitter.h | 1 + 2 files changed, 9 insertions(+) diff --git a/Common/Arm64Emitter.cpp b/Common/Arm64Emitter.cpp index ad834e1872..43dcbe4ba6 100644 --- a/Common/Arm64Emitter.cpp +++ b/Common/Arm64Emitter.cpp @@ -1547,6 +1547,10 @@ void ARM64XEmitter::CMP(ARM64Reg Rn, u32 imm, bool shift) { EncodeAddSubImmInst(1, true, shift, imm, Rn, Is64Bit(Rn) ? SP : WSP); } +void ARM64XEmitter::CMN(ARM64Reg Rn, u32 imm, bool shift) +{ + EncodeAddSubImmInst(0, true, shift, imm, Rn, Is64Bit(Rn) ? SP : WSP); +} // Data Processing (Immediate) void ARM64XEmitter::MOVZ(ARM64Reg Rd, u32 imm, ShiftAmount pos) @@ -3754,11 +3758,15 @@ bool ARM64XEmitter::TrySUBI2R(ARM64Reg Rd, ARM64Reg Rn, u64 imm) { } bool ARM64XEmitter::TryCMPI2R(ARM64Reg Rn, u64 imm) { + s64 negated = Is64Bit(Rn) ? -(s64)imm : -(s32)(u32)imm; u32 val; bool shift; if (IsImmArithmetic(imm, &val, &shift)) { CMP(Rn, val, shift); return true; + } else if (IsImmArithmetic((u64)negated, &val, &shift)) { + CMN(Rn, val, shift); + return true; } else { return false; } diff --git a/Common/Arm64Emitter.h b/Common/Arm64Emitter.h index 097d82a85a..a6ce09b3fa 100644 --- a/Common/Arm64Emitter.h +++ b/Common/Arm64Emitter.h @@ -591,6 +591,7 @@ public: void SUB(ARM64Reg Rd, ARM64Reg Rn, u32 imm, bool shift = false); void SUBS(ARM64Reg Rd, ARM64Reg Rn, u32 imm, bool shift = false); void CMP(ARM64Reg Rn, u32 imm, bool shift = false); + void CMN(ARM64Reg Rn, u32 imm, bool shift = false); // Data Processing (Immediate) void MOVZ(ARM64Reg Rd, u32 imm, ShiftAmount pos = SHIFT_0);