sannybuilder/dev

Introduce optimization options

Opened this issue · 1 comments

SCM has plenty of low hanging fruit with optimizations which can substantially reduce code size, which might be useful for some bigger projects.

Two optimizations are very simplistic and should be easy to implement:

  • Skipping if 0 statements from high level constructs. When using manual jumps/else_jumps the user might save space by not including an if statement for single conditions, but for high level constructs it's not possible.
  • Replacing 0.0f with 0 - with former being 4 bytes and latter being 1 byte, script processor evaluates them to identical values. Safe even for comparison commands, as reinterpreting integer 0 as float 0.0 is okay.

More complex optimizations? Would be welcome, but they aren't nearly as trivial:

  • Simplifying labels - with high level constructs it's very common to see else_jump -> jump -> jump.... In theory they could be optimized and maybe it'd result in size and performance optimizations.

As far as those go, the two simple optimizations are kind of "must have", label analysis is a welcome extra but I am aware that it might be more complex than it sounds, so I wouldn't consider it high priority.

x87 commented

Also dropping defined objects list saves 24 bytes per each unused object.