dplassgit / d2lang

D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
MIT License
6 stars 0 forks source link

Optimize a++ a=a+2 into a=a+3 #229

Closed dplassgit closed 1 year ago

dplassgit commented 1 year ago

As summary. Also for subtraction or really any combination of ++ and -- and + and -

dplassgit commented 1 year ago

Previously, this was handled by the AdjacentArithmeticOptimizer, but now that Inc and Dec are generated from the ILCodeGenerator (instead of a=a+1 a=a+2), that optimization was lost.