Page 1 of 1
small optimization idea
Posted: Mon Aug 17, 2009 1:16 pm
by spacy51
gba-thumb.cpp @l1587:
// LDR Rd, [Rs, #Imm]
static INSN_REGPARM void thumb68(u32 opcode)
{
if (busPrefetchCount == 0)
u32 address = reg[(opcode>>3)&7].I + b<<2)[/b];
reg[opcode&7].I = CPUReadMemory(address);
clockTicks = 3 + dataTicksAccess32(address) + codeTicksAccess16(armNextPC);
}
Couldn't the highlighted block be optimized by replacing it with
code[/code]
Â
Â
There are several cases like this around that area.
small optimization idea
Posted: Mon Aug 17, 2009 3:46 pm
by ZachBacon
I'll give it a try and see what happens [img]<fileStore.core_Emoticons>/emoticons/smile.png[/img]/emoticons/smile@2x.png 2x" width="20" height="20" />
small optimization idea
Posted: Mon Aug 17, 2009 3:54 pm
by ZachBacon
ok tried
u32 address = reg[(opcode>>3)&7].I + (((opcode>>4)&124)<<2); and it didn't work (I know not what you said to try)
so then I tried
u32 address = reg[(opcode>>3)&7].I + (((opcode>>4)&124); compile didn't work since it was missing a bracket (that was kind of your fault for not giving the extra bracket [img]<fileStore.core_Emoticons>/emoticons/tongue.png[/img]/emoticons/tongue@2x.png 2x" width="20" height="20" />)
once the extra bracket was added it worked again
u32 address = reg[(opcode>>3)&7].I + (((opcode>>4)&124));
and it was fairly optimized [img]<fileStore.core_Emoticons>/emoticons/smile.png[/img]/emoticons/smile@2x.png 2x" width="20" height="20" />
small optimization idea
Posted: Mon Aug 17, 2009 4:08 pm
by spacy51
My replacement should be perfectly fine [img]<fileStore.core_Emoticons>/emoticons/huh.png[/img]/emoticons/huh@2x.png 2x" width="20" height="20" />
Â
u32 address = reg[(opcode>>3)&7].I + b)[/b];
Â
Do you seriously want to tell me there have to be two brackets???
:blah!:
Â
It would be interesting to see the actual speed differences, if all of those similar code pieces were edited like that.
small optimization idea
Posted: Mon Aug 17, 2009 4:09 pm
by ZachBacon
well I was tired and didn't notice >_< I didn't have my coffee at all but yeah I say let's do this as an experiment first before submitting it to svn and if the others like it then submit it
small optimization idea
Posted: Mon Aug 17, 2009 4:25 pm
by spacy51
It would be cool if some binary junky can tell me if the expression (((opcode>>6)&31)<<2) always gives the same results as ((opcode>>4)&124). I only had some basic binary term transformation in school ^^. I really don't want to introduce bugs like I did before I took a break [img]<fileStore.core_Emoticons>/emoticons/laugh.png[/img]/emoticons/laugh@2x.png 2x" width="20" height="20" />
small optimization idea
Posted: Mon Aug 17, 2009 4:28 pm
by jbo_85
It would be cool if some binary junky can tell me if the expression (((opcode>>6)&31)<<2) always gives the same results as ((opcode>>4)&124). I only had some basic binary term transformation in school ^^. I really don't want to introduce bugs like I did before I took a break [img]<fileStore.core_Emoticons>/emoticons/laugh.png[/img]/emoticons/laugh@2x.png 2x" width="20" height="20" />
The two expressions are the same. But it doesn't make a difference for the release build because the compiler already optimizes it.
small optimization idea
Posted: Mon Aug 17, 2009 5:37 pm
by spacy51
Is there any proof that the compiler optimizes that? Hm, maybe it's possible to look at the assembler code the compiler produced.
small optimization idea
Posted: Mon Aug 17, 2009 5:43 pm
by jbo_85
I compared the executables.
small optimization idea
Posted: Mon Aug 17, 2009 6:04 pm
by spacy51
OK, good to know, thanks.