OrangeC icon indicating copy to clipboard operation
OrangeC copied to clipboard

Optimize register usage in loops

Open LADSoft opened this issue 5 years ago • 2 comments

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.

LADSoft avatar Oct 29 '20 00:10 LADSoft

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;

LADSoft avatar Oct 29 '20 03:10 LADSoft

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.

LADSoft avatar Jun 11 '21 23:06 LADSoft

so I handled this by rewriting the inlining; it uses registers more often.

LADSoft avatar Jun 24 '23 03:06 LADSoft