From 98113edbd4359441df7ce25241bb2ee34ba66670 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 8 May 2016 11:29:11 +0200 Subject: [PATCH] More simplify pass --- Core/MIPS/IR/IRJit.cpp | 9 ++++++--- Core/MIPS/IR/IRPassSimplify.cpp | 11 +++++------ Core/MIPS/IR/IRRegCache.cpp | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Core/MIPS/IR/IRJit.cpp b/Core/MIPS/IR/IRJit.cpp index 09f6acbe61..cc8bc8b65c 100644 --- a/Core/MIPS/IR/IRJit.cpp +++ b/Core/MIPS/IR/IRJit.cpp @@ -256,7 +256,7 @@ void IRJit::DoJit(u32 em_address, IRBlock *b) { js.compilerPC += 4; js.numInstructions++; - if (ir.GetConstants().size() > 128) { + if (ir.GetConstants().size() > 64) { // Need to break the block ir.Write(IROp::ExitToConst, ir.AddConstant(js.compilerPC)); js.compiling = false; @@ -272,6 +272,9 @@ void IRJit::DoJit(u32 em_address, IRBlock *b) { if (PropagateConstants(ir, simplified)) logBlocks = 1; code = &simplified; + // Some blocks in tekken generate curious numbers of constants after propagation. + //if (ir.GetConstants().size() >= 64) + // logBlocks = 1; } b->SetInstructions(code->GetInstructions(), code->GetConstants()); @@ -287,7 +290,7 @@ void IRJit::DoJit(u32 em_address, IRBlock *b) { } if (logBlocks > 0 && dontLogBlocks == 0) { - ILOG("=============== Original IR (%d instructions) ===============", (int)ir.GetInstructions().size()); + ILOG("=============== Original IR (%d instructions, %d const) ===============", (int)ir.GetInstructions().size(), (int)ir.GetConstants().size()); for (int i = 0; i < ir.GetInstructions().size(); i++) { char buf[256]; DisassembleIR(buf, sizeof(buf), ir.GetInstructions()[i], ir.GetConstants().data()); @@ -297,7 +300,7 @@ void IRJit::DoJit(u32 em_address, IRBlock *b) { } if (logBlocks > 0 && dontLogBlocks == 0) { - ILOG("=============== IR (%d instructions) ===============", (int)code->GetInstructions().size()); + ILOG("=============== IR (%d instructions, %d const) ===============", (int)code->GetInstructions().size(), (int)code->GetConstants().size()); for (int i = 0; i < code->GetInstructions().size(); i++) { char buf[256]; DisassembleIR(buf, sizeof(buf), code->GetInstructions()[i], code->GetConstants().data()); diff --git a/Core/MIPS/IR/IRPassSimplify.cpp b/Core/MIPS/IR/IRPassSimplify.cpp index d5b943c23c..5eb1ea8001 100644 --- a/Core/MIPS/IR/IRPassSimplify.cpp +++ b/Core/MIPS/IR/IRPassSimplify.cpp @@ -62,7 +62,7 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) { bool symmetric = true; switch (inst.op) { case IROp::SetConst: - gpr.SetImm((MIPSGPReg)inst.dest, constants[inst.src1]); + gpr.SetImm(inst.dest, constants[inst.src1]); break; case IROp::Sub: @@ -83,7 +83,7 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) { } else { out.Write(ArithToArithConst(inst.op), inst.dest, inst.src1, out.AddConstant(gpr.GetImm(inst.src2))); } - } else if (gpr.IsImm(inst.src1) && inst.src1 != inst.src2 && inst.dest != inst.src2 && symmetric) { + } else if (symmetric && gpr.IsImm(inst.src1) && inst.src1 != inst.src2 && inst.dest != inst.src2) { gpr.MapDirtyIn(inst.dest, inst.src2); out.Write(ArithToArithConst(inst.op), inst.dest, inst.src2, out.AddConstant(gpr.GetImm(inst.src1))); } else { @@ -91,7 +91,7 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) { goto doDefault; } break; - + case IROp::AddConst: case IROp::SubConst: case IROp::AndConst: @@ -120,7 +120,7 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) { break; case IROp::Mov: - if (inst.src1 == inst.src2) { + if (inst.dest == inst.src1) { // Nop } else if (gpr.IsImm(inst.src1)) { gpr.SetImm(inst.dest, gpr.GetImm(inst.src1)); @@ -148,10 +148,9 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) { case IROp::Load16: case IROp::Load16Ext: case IROp::Load32: - if (gpr.IsImm(inst.src1) && inst.src1 != inst.dest && inst.src2 != inst.dest) { + if (gpr.IsImm(inst.src1) && inst.src1 != inst.dest) { gpr.MapDirty(inst.dest); out.Write(inst.op, inst.dest, 0, out.AddConstant(gpr.GetImm(inst.src1) + constants[inst.src2])); - logBlocks = true; } else { gpr.MapDirtyIn(inst.dest, inst.src1); goto doDefault; diff --git a/Core/MIPS/IR/IRRegCache.cpp b/Core/MIPS/IR/IRRegCache.cpp index c7e11aa6d9..09aeeb9c90 100644 --- a/Core/MIPS/IR/IRRegCache.cpp +++ b/Core/MIPS/IR/IRRegCache.cpp @@ -26,7 +26,7 @@ IRRegCache::IRRegCache(IRWriter *ir) : ir_(ir) { void IRRegCache::FlushAll() { for (int i = 0; i < TOTAL_MAPPABLE_MIPSREGS; i++) { - if (i < IRTEMP_0) + //if (i < IRTEMP_0) Flush(i); } }