### Implement forward substitution of constants in the Cmm mini-inliner

Currently the mini-inliner would only forward substitute assignments to registers that were used exactly once, to not risk duplicating computation. For constants there's no such risk so we always substitute. Prior to the change the Cmm fn { bits64 a, b; a = 1; b = a + a; RET_N(b); } would be optimized as fn() { [] } ca: _cb::I64 = 1; R1 = _cb::I64 + _cb::I64; jump (I64[Sp + 0]) (); } but after it would be optimized as fn() { [] } ca: R1 = 2; jump (I64[Sp + 0]) (); } Note that this pass does not deal with the now dead assignment.

Showing

Please register or sign in to comment