From 4afbd871886896147d83f67ead359e0320ba0f3b Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Tue, 10 Aug 2021 05:37:13 +0200 Subject: [PATCH] PowerPC: Fast path in InvalidateICache is only valid if the address is 32-byte aligned. --- Source/Core/Core/PowerPC/JitCommon/JitCache.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index e09443dcc8..53b36a0025 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -190,9 +190,11 @@ void JitBaseBlockCache::InvalidateICache(u32 address, u32 length, bool forced) return; const u32 physical_address = translated.address; - // Optimize the common case of length == 32 which is used by Interpreter::dcb* + // Optimization for the case of invalidating a single cache line, which is used by the dcb* + // instructions. If the valid_block bit for that cacheline is not set, we can safely skip + // the remaining invalidation logic. bool destroy_block = true; - if (length == 32) + if (length == 32 && (physical_address & 0x1fu) == 0) { if (!valid_block.Test(physical_address / 32)) destroy_block = false;