Jens von der Heydt
2006-04-26 11:31:53 UTC
Hi folks,
I was reading through jitc.log when I found some
small assembler parts that really could be easily optimized.
for example something like this:
mflr r0
mov eax, [ lr ]
mov ecd, eax
.
That's pretty easy and ok. But what I asked myself was why It did
something like the above
even in the case that another register (nearly 3-4 opcodes ealier)
already contained [ lr ]
and wasn't re-used. So there should be cases where we can actually
save one of
the above moves.
So I changed function move_mem (reg1, reg2..) in x86asm.c:
Org:
static void inline move_reg(PPC_Register creg1, PPC_Register creg2)
{
NativeReg reg2 = jitcGetClientRegister(creg2);
NativeReg reg1 = jitcMapClientRegisterDirty(creg1);
asmALURegReg(X86_MOV, reg1, reg2);
}
to this:
static void inline move_reg(PPC_Register creg1, PPC_Register creg2)
{
NativeReg reg = jitcGetClientRegisterMapping(creg2);
if (reg == REG_NO) {
NativeReg reg2 = jitcGetClientRegister(creg2);
NativeReg reg1 = jitcMapClientRegisterDirty(creg1);
asmALURegReg(X86_MOV, reg1, reg2);
} else {
NativeReg reg1 = jitcMapClientRegisterDirty(creg1);
asmALURegReg(X86_MOV, reg1, reg);
}
}
This does work for me and produces more optimized assembler when
possible.
Booting OSX generated about 23,000 times optimized versions of
register moves.
The interesting bit is that when running XBench (5 times per Test) I get
around 7.484 Points, and with optimization I get 13.176 Points.
That's quite a difference I would say. I would not imagine such a small
assembler change to have so dramatic effect. I wonder if the above
function
is right at all, since my jitc practive is very limited. Please have
a look and comment.
Jens
I was reading through jitc.log when I found some
small assembler parts that really could be easily optimized.
for example something like this:
mflr r0
mov eax, [ lr ]
mov ecd, eax
.
That's pretty easy and ok. But what I asked myself was why It did
something like the above
even in the case that another register (nearly 3-4 opcodes ealier)
already contained [ lr ]
and wasn't re-used. So there should be cases where we can actually
save one of
the above moves.
So I changed function move_mem (reg1, reg2..) in x86asm.c:
Org:
static void inline move_reg(PPC_Register creg1, PPC_Register creg2)
{
NativeReg reg2 = jitcGetClientRegister(creg2);
NativeReg reg1 = jitcMapClientRegisterDirty(creg1);
asmALURegReg(X86_MOV, reg1, reg2);
}
to this:
static void inline move_reg(PPC_Register creg1, PPC_Register creg2)
{
NativeReg reg = jitcGetClientRegisterMapping(creg2);
if (reg == REG_NO) {
NativeReg reg2 = jitcGetClientRegister(creg2);
NativeReg reg1 = jitcMapClientRegisterDirty(creg1);
asmALURegReg(X86_MOV, reg1, reg2);
} else {
NativeReg reg1 = jitcMapClientRegisterDirty(creg1);
asmALURegReg(X86_MOV, reg1, reg);
}
}
This does work for me and produces more optimized assembler when
possible.
Booting OSX generated about 23,000 times optimized versions of
register moves.
The interesting bit is that when running XBench (5 times per Test) I get
around 7.484 Points, and with optimization I get 13.176 Points.
That's quite a difference I would say. I would not imagine such a small
assembler change to have so dramatic effect. I wonder if the above
function
is right at all, since my jitc practive is very limited. Please have
a look and comment.
Jens