JitIL: a couple small optimizations.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2286 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
magumagu9 2009-02-17 10:39:50 +00:00
parent 1e150bccdf
commit 9ed368b35a
3 changed files with 30 additions and 1 deletions

View File

@ -326,6 +326,19 @@ InstLoc IRBuilder::FoldUOp(unsigned Opcode, InstLoc Op1, unsigned extra) {
if (Opcode == DoubleToSingle) {
if (getOpcode(*Op1) == DupSingleToMReg)
return getOp1(Op1);
if (getOpcode(*Op1) >= FDMul || getOpcode(*Op1) <= FDSub) {
InstLoc OOp1 = getOp1(Op1), OOp2 = getOp2(Op1);
if (getOpcode(*OOp1) == DupSingleToMReg &&
getOpcode(*OOp2) == DupSingleToMReg) {
if (getOpcode(*Op1) == FDMul) {
return FoldBiOp(FSMul, getOp1(OOp1), getOp2(OOp2));
} else if (getOpcode(*Op1) == FDAdd) {
return FoldBiOp(FSAdd, getOp1(OOp1), getOp2(OOp2));
} else if (getOpcode(*Op1) == FDSub) {
return FoldBiOp(FSSub, getOp1(OOp1), getOp2(OOp2));
}
}
}
}
return EmitUOp(Opcode, Op1, extra);
@ -1341,6 +1354,7 @@ static void DoWriteCode(IRBuilder* ibuild, Jit64* Jit, bool UseProfile) {
case StoreCTR:
case StoreMSR:
case StoreGQR:
case StoreSRR:
case StoreFReg:
if (!isImm(*getOp1(I)))
regMarkUse(RI, I, getOp1(I), 1);
@ -1527,6 +1541,13 @@ static void DoWriteCode(IRBuilder* ibuild, Jit64* Jit, bool UseProfile) {
regNormalRegClear(RI, I);
break;
}
case StoreSRR: {
unsigned srr = *I >> 16;
regStoreInstToConstLoc(RI, 32, getOp1(I),
&PowerPC::ppcState.spr[SPR_SRR0+srr]);
regNormalRegClear(RI, I);
break;
}
case StoreCarry: {
Jit->CMP(32, regLocForInst(RI, getOp1(I)), Imm8(0));
FixupBranch nocarry = Jit->J_CC(CC_Z);

View File

@ -56,6 +56,7 @@ namespace IREmitter {
StoreMSR,
StoreFPRF,
StoreGQR,
StoreSRR,
// Arbitrary interpreter instruction
InterpreterFallback,
@ -491,6 +492,9 @@ namespace IREmitter {
InstLoc EmitStoreGQR(InstLoc op1, unsigned gqr) {
return FoldUOp(StoreGQR, op1, gqr);
}
InstLoc EmitStoreSRR(InstLoc op1, unsigned srr) {
return FoldUOp(StoreSRR, op1, srr);
}
void StartBackPass() { curReadPtr = &InstList[InstList.size()]; }
void StartForwardPass() { curReadPtr = &InstList[0]; }

View File

@ -55,6 +55,10 @@
case SPR_GQR0 + 7:
ibuild.EmitStoreGQR(ibuild.EmitLoadGReg(inst.RD), iIndex - SPR_GQR0);
return;
case SPR_SRR0:
case SPR_SRR1:
ibuild.EmitStoreSRR(ibuild.EmitLoadGReg(inst.RD), iIndex - SPR_SRR0);
return;
default:
Default(inst);
return;