Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#170 optimization patch

open
nobody
None
5
2012-09-07
2006-06-07
Keith
No

get rid of memory accesses, in exchange do a shift
get rid of jump of if (bool) var++ and similiar code, instead does var+=(bool)
change switch statements <4 to if then (if then is faster than switch <4)
change most common path from dword to word
unroll dyn_savestate & dyn_loadstate explicitly(gprof says it makes dosbox happy)
common path optimizations for cache_openblock
the one line comments were converted from / / to // to save me time commenting out large blocks quickly
got rid of the breaks in the large case statement in createcacheblock by reordering and filling in missing cases so that it gets compiled to one big jump table.
bonus is you also see more readily which opcodes are not yet implemented dynamically.

Discussion

  • Keith
    Keith
    2006-06-07

     
    Attachments
  • Max Horn
    Max Horn
    2007-11-22

    Logged In: YES
    user_id=12935
    Originator: NO

    If I may be so bold, I'd like to say that not all of these changes make sense with modern compilers, some even may have negative effect:

    • Storing "address>>12" in a temp var will not automatically result in a memory access; in fact any reasonable compiler will generate identical code with or without the changes to mem_readb_inline etc. proposed here. To the contrary, in other situations it may help the compiler to produce better code if it knows that a certain value will stay fixed all the time.

    • "Switch statements < 4 are slower" -- again, any reasonable compiler will produce identical code in both cases. Even w/o optimizations turned on, the question of which is faster depends on the compiler&target system/CPU