> A classic compiler optimisation is to fuse these two loops together, so that you only iterate over a once
Honest question: why is that true? If x is the cost of running one iteration of the first loop and y is the cost for the second loop then the total cost is:
There's a tonne of work done in this space, e.g. Mary Sheeran's µFP from the early 1980s [1], at least for classical synchronous digital circuits. Some googling will dig up a survey or two on modelling circuits with functions and a variety of systems in various languages. BlueSpec was and perhaps is interesting too but is quite a different approach.
2 comments:
> A classic compiler optimisation is to fuse these two loops together, so that you only iterate over a once
Honest question: why is that true? If x is the cost of running one iteration of the first loop and y is the cost for the second loop then the total cost is:
After fusing, the cost is: which is the same.There's a tonne of work done in this space, e.g. Mary Sheeran's µFP from the early 1980s [1], at least for classical synchronous digital circuits. Some googling will dig up a survey or two on modelling circuits with functions and a variety of systems in various languages. BlueSpec was and perhaps is interesting too but is quite a different approach.
[1] see e.g. https://www.jucs.org/jucs_11_7/hardware_design_and_functiona...