CPU/Recompiler: Optimize away nops completely

35% performance improvement for PGXP CPU mode in Racing Lagoon.
This commit is contained in:
Connor McLaughlin 2021-05-25 20:01:56 +10:00
parent f4242f390b
commit baad1a4b23
4 changed files with 15 additions and 0 deletions

View file

@ -65,6 +65,13 @@ bool CodeGenerator::CompileBlock(CodeBlock* block, CodeBlock::HostCodePointer* o
bool CodeGenerator::CompileInstruction(const CodeBlockInstruction& cbi)
{
if (IsNopInstruction(cbi.instruction))
{
InstructionPrologue(cbi, 1);
InstructionEpilogue(cbi);
return true;
}
bool result;
switch (cbi.instruction.op)
{

View file

@ -214,6 +214,7 @@ private:
//////////////////////////////////////////////////////////////////////////
bool CompileInstruction(const CodeBlockInstruction& cbi);
bool Compile_Fallback(const CodeBlockInstruction& cbi);
bool Compile_Nop(const CodeBlockInstruction& cbi);
bool Compile_Bitwise(const CodeBlockInstruction& cbi);
bool Compile_Shift(const CodeBlockInstruction& cbi);
bool Compile_Load(const CodeBlockInstruction& cbi);

View file

@ -13,6 +13,12 @@ const char* GetRegName(Reg reg)
return s_reg_names[static_cast<u8>(reg)];
}
bool IsNopInstruction(const Instruction& instruction)
{
// TODO: Handle other types of nop.
return (instruction.bits == 0);
}
bool IsBranchInstruction(const Instruction& instruction)
{
switch (instruction.op)

View file

@ -220,6 +220,7 @@ union Instruction
};
// Instruction helpers.
bool IsNopInstruction(const Instruction& instruction);
bool IsBranchInstruction(const Instruction& instruction);
bool IsUnconditionalBranchInstruction(const Instruction& instruction);
bool IsDirectBranchInstruction(const Instruction& instruction);