Save a few bytes on const flushing using 5 byte eax movs for 0 and -1 instead of 10 byte immediate movs.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@808 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
sudonim1 2009-03-17 20:58:59 +00:00
parent 43c0d895ad
commit fa3288971f
1 changed files with 55 additions and 9 deletions

View File

@ -139,16 +139,62 @@ void _flushConstReg(int reg)
void _flushConstRegs()
{
int i;
int i, j;
int zero_cnt = 0, minusone_cnt = 0;
int eaxval = 1; // 0, -1
unsigned long done[4] = {0, 0, 0, 0};
u8* rewindPtr;
// flush constants
// flush 0 and -1 first
// ignore r0
for(i = 1; i < 32; ++i) {
if( g_cpuHasConstReg & (1<<i) ) {
for (i = 1, j = 0; i < 32; j++ && ++i, j %= 2) {
if (!GPR_IS_CONST1(i) || g_cpuFlushedConstReg & (1<<i))
continue;
if (g_cpuConstRegs[i].SL[j] != 0)
continue;
if (eaxval != 0)
XOR32RtoR(EAX, EAX), eaxval = 0;
MOV32RtoM((uptr)&cpuRegs.GPR.r[i].SL[j], EAX);
done[j] |= 1<<i;
zero_cnt++;
}
if( !(g_cpuFlushedConstReg&(1<<i)) ) {
rewindPtr = x86Ptr[_EmitterId_];
for (i = 1, j = 0; i < 32; j++ && ++i, j %= 2) {
if (!GPR_IS_CONST1(i) || g_cpuFlushedConstReg & (1<<i))
continue;
if (g_cpuConstRegs[i].SL[j] != -1)
continue;
#if 1
if (eaxval > 0)
XOR32RtoR(EAX, EAX), eaxval = 0;
#else
if (eaxval > 0)
MOV32ItoR(EAX, -1), eaxval = -1;
#endif
if (eaxval == 0)
NOT32R(EAX), eaxval = -1;
MOV32RtoM((uptr)&cpuRegs.GPR.r[i].SL[j], EAX);
done[j + 2] |= 1<<i;
minusone_cnt++;
}
if (minusone_cnt == 1 && !zero_cnt) { // not worth it for one byte
x86Ptr[_EmitterId_] = rewindPtr;
} else {
done[0] |= done[2];
done[1] |= done[3];
}
for (i = 1; i < 32; ++i) {
if (GPR_IS_CONST1(i)) {
if (!(g_cpuFlushedConstReg&(1<<i))) {
if (!(done[0] & (1<<i)))
MOV32ItoM((uptr)&cpuRegs.GPR.r[i].UL[0], g_cpuConstRegs[i].UL[0]);
if (!(done[1] & (1<<i)))
MOV32ItoM((uptr)&cpuRegs.GPR.r[i].UL[1], g_cpuConstRegs[i].UL[1]);
g_cpuFlushedConstReg |= 1<<i;
}