dplassgit / d2lang

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

Optimize 1 + i + 1 to i + 2 #175

Closed dplassgit closed 2 years ago

dplassgit commented 2 years ago

Not sure where this could be done

dplassgit commented 2 years ago

It could be like the inc/dec optimizer:

temp1 = i + constant1
temp2 = temp1 + constant2

becomes

temp2 = i + (constant1 + constant2)