armjit: Optimize out a few immediate logic cases.

This commit is contained in:
Unknown W. Brackets committed 2013-11-08 11:39:24 -08:00
1 parent 385f9a457e
commit 02dd250354
2 files changed
+31 -1

No files matched your search

+30
View File
@@ -100,6 +100,10 @@ namespace MIPSComp
case 10: // R(rt) = (s32)R(rs) < simm; break; //slti
{
if (gpr.IsImm(rs)) {
gpr.SetImm(rt, (s32)gpr.GetImm(rs) < simm ? 1 : 0);
break;
}
gpr.MapDirtyIn(rt, rs);
CMPI2R(gpr.R(rs), simm, R0);
SetCC(CC_LT);
@@ -112,6 +116,10 @@ namespace MIPSComp
case 11: // R(rt) = R(rs) < uimm; break; //sltiu
{
if (gpr.IsImm(rs)) {
gpr.SetImm(rt, gpr.GetImm(rs) < suimm ? 1 : 0);
break;
}
gpr.MapDirtyIn(rt, rs);
CMPI2R(gpr.R(rs), suimm, R0);
SetCC(CC_LO);
@@ -145,10 +153,32 @@ namespace MIPSComp
switch (op & 63)
{
case 22: //clz
if (gpr.IsImm(rs)) {
u32 value = gpr.GetImm(rs);
int x = 31;
int count = 0;
while (!(value & (1 << x)) && x >= 0) {
count++;
x--;
}
gpr.SetImm(rd, count);
break;
}
gpr.MapDirtyIn(rd, rs);
CLZ(gpr.R(rd), gpr.R(rs));
break;
case 23: //clo
if (gpr.IsImm(rs)) {
u32 value = gpr.GetImm(rs);
int x = 31;
int count = 0;
while ((value & (1 << x)) && x >= 0) {
count++;
x--;
}
gpr.SetImm(rd, count);
break;
}
gpr.MapDirtyIn(rd, rs);
MVN(R0, gpr.R(rs));
CLZ(gpr.R(rd), R0);
+1 -1
View File
@@ -96,7 +96,7 @@ namespace MIPSComp
break;
case 10: // R(rt) = (s32)R(rs) < simm; break; //slti
// There's a mips compiler out there asking it already knows the answer to...
// There's a mips compiler out there asking questions it already knows the answer to...
if (gpr.IsImmediate(rs))
{
gpr.SetImmediate32(rt, (s32)gpr.GetImmediate32(rs) < simm);