OrangeC
OrangeC copied to clipboard
Optimize register usage in loops
when for-range is used for example on vectors, the resulting code generation is somewhat awful. Loop handling for tight loops would work better if the reference optimizations were optimized away and things were moved into registers.
i thought initially this swould involve work in the optimizer, but now I think it can be done as an optimization during parsing if the for-range iterator is a pointer;
reference variables seem to be put into a temporary stack variable when inlining. There probably isn't a good reason for that... there may be further optimizations available such as loading the value the reference is pointing to, if it can be proved the function never writes to the reference variable.
so I handled this by rewriting the inlining; it uses registers more often.