ForNeVeR / Cesium

C compiler for the CLI platform
MIT License
374 stars 39 forks source link

Optimize codegen for postfix increment operators #648

Open ForNeVeR opened 1 month ago

ForNeVeR commented 1 month ago

Right now, after #647, for operator like a = b++, we emit codegen analogous to b = b + 1; a = b - 1;

Let's check how C# implements this and possibly optimize.

Avinashs7 commented 1 month ago

The assignment occurs first and then the increment right? Or is this what you are been asking to change @ForNeVeR

ForNeVeR commented 1 month ago

The assignment should be first, and the increment second, yes. I am not asking to change that.

I am asking to change the codegen that desugars increment into first increment and then decrement!

See how C# does this: no decrement anywhere. dup and then add.