![]() |
|
small optimization idea - Printable Version +- VBA-M Forums (http://vba-m.com/forum) +-- Forum: VisualBoy Advance-M (/Forum-visualboy-advance-m) +--- Forum: Suggestions (/Forum-suggestions) +---- Forum: Core (/Forum-core--44) +---- Thread: small optimization idea (/Thread-small-optimization-idea) |
small optimization idea - spacy51 - 08-18-2009 03:16 AM gba-thumb.cpp @l1587: Quote:// LDR Rd, [Rs, #Imm]Couldn't the highlighted block be optimized by replacing it with Code: ((opcode>>4)&124)There are several cases like this around that area. RE: small optimization idea - Zach Thibeau - 08-18-2009 05:46 AM I'll give it a try and see what happens
RE: small optimization idea - Zach Thibeau - 08-18-2009 05:54 AM 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 )once the extra bracket was added it worked again u32 address = reg[(opcode>>3)&7].I + (((opcode>>4)&124)); and it was fairly optimized
RE: small optimization idea - spacy51 - 08-18-2009 06:08 AM My replacement should be perfectly fine o.o (08-18-2009 05:54 AM)Zach Thibeau Wrote: u32 address = reg[(opcode>>3)&7].I + (((opcode>>4)&124)); Do you seriously want to tell me there have to be two brackets??? ![]() It would be interesting to see the actual speed differences, if all of those similar code pieces were edited like that. RE: small optimization idea - Zach Thibeau - 08-18-2009 06:09 AM 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 RE: small optimization idea - spacy51 - 08-18-2009 06:25 AM 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 xD RE: small optimization idea - jbo_85 - 08-18-2009 06:28 AM (08-18-2009 06:25 AM)spacy51 Wrote: 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 xDThe two expressions are the same. But it doesn't make a difference for the release build because the compiler already optimizes it. RE: small optimization idea - spacy51 - 08-18-2009 07:37 AM Is there any proof that the compiler optimizes that? Hm, maybe it's possible to look at the assembler code the compiler produced. RE: small optimization idea - jbo_85 - 08-18-2009 07:43 AM I compared the executables. RE: small optimization idea - spacy51 - 08-18-2009 08:04 AM OK, good to know, thanks. |