Refine idle loop detector.
Some checks failed
Build iOS / build_ios (push) Has been cancelled
Build Android / build_android (apk) (push) Has been cancelled
Build Android / build_android (libretro) (push) Has been cancelled
Build JavaScript / build_js (push) Has been cancelled
Build Linux / build_linux (push) Has been cancelled
Build Linux ARM32 / build_linux_arm32 (push) Has been cancelled
Build Linux ARM64 / build_linux_arm64 (push) Has been cancelled
Build macOS / build_macos (push) Has been cancelled
Build Windows / build_windows (x86_32, Visual Studio 16 2019, installer32.nsi, win32_msvc2019, Win32) (push) Has been cancelled
Build Windows / build_windows (x86_64, Visual Studio 16 2019, installer64.nsi, win64_msvc2019_64, x64) (push) Has been cancelled
Build Windows Psf / build_windows_psf (off, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Has been cancelled
Build Windows Psf / build_windows_psf (on, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Has been cancelled
Check Format / run_clangformat (push) Has been cancelled

This commit is contained in:
Jean-Philip Desjardins 2025-03-10 18:09:36 -04:00
parent fe8a7a0561
commit 883f29ef19

View file

@ -42,6 +42,7 @@ bool CEeBasicBlock::IsCodeIdleLoopBlock() const
{ {
OP_BEQ = 0x04, OP_BEQ = 0x04,
OP_BNE = 0x05, OP_BNE = 0x05,
OP_ADDIU = 0x09,
OP_SLTIU = 0x0B, OP_SLTIU = 0x0B,
OP_ANDI = 0x0C, OP_ANDI = 0x0C,
OP_XORI = 0x0E, OP_XORI = 0x0E,
@ -53,6 +54,8 @@ bool CEeBasicBlock::IsCodeIdleLoopBlock() const
enum enum
{ {
OP_SPECIAL_SLL = 0x00,
OP_SPECIAL_ADDU = 0x21,
OP_SPECIAL_SLT = 0x2A, OP_SPECIAL_SLT = 0x2A,
OP_SPECIAL_SLTU = 0x2B, OP_SPECIAL_SLTU = 0x2B,
}; };
@ -110,6 +113,11 @@ bool CEeBasicBlock::IsCodeIdleLoopBlock() const
case 0x00: case 0x00:
switch(special) switch(special)
{ {
case OP_SPECIAL_SLL:
newUse = (1 << rt);
newDef = (1 << rd);
break;
case OP_SPECIAL_ADDU:
case OP_SPECIAL_SLT: case OP_SPECIAL_SLT:
case OP_SPECIAL_SLTU: case OP_SPECIAL_SLTU:
newUse = (1 << rs) | (1 << rt); newUse = (1 << rs) | (1 << rt);
@ -126,6 +134,7 @@ bool CEeBasicBlock::IsCodeIdleLoopBlock() const
case OP_LW: case OP_LW:
case OP_LQ: case OP_LQ:
case OP_LBU: case OP_LBU:
case OP_ADDIU:
case OP_SLTIU: case OP_SLTIU:
case OP_XORI: case OP_XORI:
newUse = (1 << rs); newUse = (1 << rs);
@ -136,17 +145,17 @@ bool CEeBasicBlock::IsCodeIdleLoopBlock() const
return false; return false;
} }
//Remove uses from defs within this block
newUse &= ~defState;
useState |= newUse;
//Bail if this defines any state that we previously used //Bail if this defines any state that we previously used
if(useState & newDef) if(useState & newDef)
{ {
return false; return false;
} }
//Remove uses from defs within this block
newUse &= ~defState;
defState |= newDef; defState |= newDef;
useState |= newUse;
} }
//Just make sure that we've at least defined our comparision register //Just make sure that we've at least defined our comparision register