stevehalliwell / ulox

A bytecode interpreted scripting language for games in Unity.
MIT License
24 stars 0 forks source link

Optimiser should be commutativity/associativity aware #256

Closed stevehalliwell closed 3 months ago

stevehalliwell commented 3 months ago

Presently the optimiser will registerise based on pattern of is the previous instruction a GET_LOCAL take it internal and remove that, if the next previous is a GET_LOCAL, take that too and remove it.

The issue is this catches

var a = 1;
var b = 2;
var c = 0;
c = a + b;

but not

var i = 0;
i += 1;