From 14c4f4e7f67ef9999bfc33bfdca80bf55d2891c7 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 12 Feb 2023 19:56:39 -0800 Subject: [PATCH] PPCCache: Update PLRU on any cache access The previous code only updated the PLRU on cache misses, which made it so that the least recently inserted cache block was evicted, instead of the least recently used/hit one. This regressed in 9d39647f9e3be1bdc2ee2cfc5ce6af2e560b4cc1 (part of #11183, but it was fine in e97d3804373b31724d0f092d8132e5ba23dec4a5), although beforehand it was only implemented for the instruction cache, and the instruction cache hit extremely infrequently when the JIT or cached interpreter is in use, which generally keeps it from behaving correctly (the pure interpreter behaves correctly with it). I'm not aware of any games that are affected by this, though I did not do extensive testing. --- Source/Core/Core/PowerPC/PPCCache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCCache.cpp b/Source/Core/Core/PowerPC/PPCCache.cpp index de1b214e29..9d4cf00083 100644 --- a/Source/Core/Core/PowerPC/PPCCache.cpp +++ b/Source/Core/Core/PowerPC/PPCCache.cpp @@ -269,12 +269,12 @@ std::pair Cache::GetCache(u32 addr, bool locked) addrs[set][way] = addr; valid[set] |= (1 << way); modified[set] &= ~(1 << way); - - // update plru - if (way != 0xff) - plru[set] = (plru[set] & ~s_plru_mask[way]) | s_plru_value[way]; } + // update plru + if (way != 0xff) + plru[set] = (plru[set] & ~s_plru_mask[way]) | s_plru_value[way]; + return {set, way}; }