pure-c / purec

C backend for PureScript
232 stars 8 forks source link

Inline common operators #43

Open felixSchl opened 5 years ago

felixSchl commented 5 years ago

Implement an equivalent for the inlineCommonOperators pass in PureScript.

https://github.com/purescript/purescript/blob/master/src/Language/PureScript/CoreImp/Optimizer/Inliner.hs#L109

I think a good few hours can be sunk into this one alone, but will be worth it. We should be able to apply the extra optimization of unboxing literals where applicable or even statically computing results where applicable. For reference, see: https://github.com/pure-c/pure-c/blob/cb4c6ffad5af96928c5934ea29138fbb9ae708a3/src/Language/PureScript/CodeGen/C/Optimizer/Inliner.purs#L222-L242

felixSchl commented 5 years ago

Note that this transform is required at least for apply and applyFlipped in order for TCO to kick in.