From 7bf1742434face90795b44f4203b7a06a419a57c Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 20 Jan 2023 19:19:47 -0800 Subject: [PATCH] Arm64: Merge two loads in to an LDP We can do a single LDP upfront when loading from the code cache, which saves an instruction and one LDP costs the same as a single LDR. Itty bitty optimization in the hot dispatcher. --- .../Interface/Core/Dispatcher/Arm64Dispatcher.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/External/FEXCore/Source/Interface/Core/Dispatcher/Arm64Dispatcher.cpp b/External/FEXCore/Source/Interface/Core/Dispatcher/Arm64Dispatcher.cpp index 5d0be4db0..3814d8e38 100644 --- a/External/FEXCore/Source/Interface/Core/Dispatcher/Arm64Dispatcher.cpp +++ b/External/FEXCore/Source/Interface/Core/Dispatcher/Arm64Dispatcher.cpp @@ -155,14 +155,16 @@ void Arm64Dispatcher::EmitDispatcher() { // Shift the offset by the size of the block cache entry add(ARMEmitter::XReg::x0, ARMEmitter::XReg::x0, ARMEmitter::XReg::x1, ARMEmitter::ShiftType::LSL, (int)log2(sizeof(FEXCore::LookupCache::LookupCacheEntry))); - // Load the guest address first to ensure it maps to the address we are currently at + // The the full LookupCacheEntry with a single LDP. + // Check the guest address first to ensure it maps to the address we are currently at. // This fixes aliasing problems - ldr(ARMEmitter::XReg::x1, ARMEmitter::Reg::r0, offsetof(FEXCore::LookupCache::LookupCacheEntry, GuestCode)); + ldp(ARMEmitter::XReg::x3, ARMEmitter::XReg::x1, ARMEmitter::Reg::r0, 0); + + // If the guest address doesn't match, Compile the block. cmp(ARMEmitter::XReg::x1, RipReg); b(ARMEmitter::Condition::CC_NE, &NoBlock); - // Now load the actual host block to execute if we can - ldr(ARMEmitter::XReg::x3, ARMEmitter::Reg::r0, offsetof(FEXCore::LookupCache::LookupCacheEntry, HostCode)); + // Check the host address to see if it matches, else compile the block. cbz(ARMEmitter::Size::i64Bit, ARMEmitter::Reg::r3, &NoBlock); // If we've made it here then we have a real compiled block