From a6d5a7ea9e82141a1383df8d5896321fb0fbc9ff Mon Sep 17 00:00:00 2001 From: magumagu9 Date: Sat, 22 Nov 2008 20:49:58 +0000 Subject: [PATCH] Fix the dirty bit and make the register cache use it to be a bit more clever: it skips storing a register back to memory if its value hasn't changed. This happens with stuff like compares and fast memory loads. This is the first in a series of enhancements I have in my tree for the jit that I plan to commit over the next few hours. I'm likely to cause some breakage, so if you see regrassions, please report them; if you can track them down to a specific revision, that would be very helpful. I'm trying to make the changes small to allow pinpointing regressions more easily. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1252 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp index 645475d92e..2392f22dd3 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp @@ -198,6 +198,7 @@ namespace Jit64 if (regs[preg].away && regs[preg].location.IsSimpleReg()) { xregs[regs[preg].location.GetSimpleReg()].free = true; + xregs[regs[preg].location.GetSimpleReg()].dirty = false; regs[preg].away = false; } } @@ -291,7 +292,7 @@ namespace Jit64 if (xlocks[xr]) PanicAlert("GetFreeXReg returned locked register"); xregs[xr].free = false; xregs[xr].ppcReg = i; - xregs[xr].dirty = makeDirty; + xregs[xr].dirty = makeDirty || regs[i].location.IsImm(); OpArg newloc = ::Gen::R(xr); if (doLoad || regs[i].location.IsImm()) MOV(32, newloc, regs[i].location); @@ -321,11 +322,13 @@ namespace Jit64 { if (regs[i].away) { + bool doStore = true; if (regs[i].location.IsSimpleReg()) { X64Reg xr = RX(i); xregs[xr].free = true; xregs[xr].ppcReg = -1; + doStore = xregs[xr].dirty; xregs[xr].dirty = false; } else @@ -333,7 +336,8 @@ namespace Jit64 //must be immediate - do nothing } OpArg newLoc = GetDefaultLocation(i); - MOV(32, newLoc, regs[i].location); + if (doStore) + MOV(32, newLoc, regs[i].location); regs[i].location = newLoc; regs[i].away = false; }