mmcloughlin/addchain

alg/opt: generic optimization

mmcloughlin opened this issue · 1 comments

We currently have the opt.Optimize() function which removes one form of obvious redundancy.

Are there any other "generic" optimization passes like this we can perform?

An addition chain is like an extremely simple SSA form. Can we learn anything from SSA optimizers?

I was playing with the existing redundancy-removal opt pass. It picks one set of extraneous chain entries to remove, but there are multiple options. My quick hack was to remove bigger values first instead of smaller values, because they tend to be more expensive to generate but a better plan is probably to do an actual cost calculation to decide which subset to keep. That’ll be more expensive to calculate, though.

https://twitter.com/commaok/status/1454906489626193921