2 ms·
Not really. If a self tail recursive function does not benefit from the optimisation that could be triggered by loopify, the generated code between the tail cal
by chambart 2y ago
Not really. If a self tail recursive function does not benefit from the optimisation that could be triggered by loopify, the generated code between the tail calls and the loop branch are almost exactly the same (some difference in code layout might happen). OCaml is already very good with that kind of code.
This pass is mostly about triggering other optimisations. Another thing is that it is applied before inlining. So if a potential for that where triggered by inlining, we might want to go through the whole process of optimizing that function. This is not something that we do by default since it is quite expensive. Also we often prefer when the performances are somewhat predictable. And inlining is notably not really predictable by default. So if you were to rely on that kind of change to do some magic on your code, maybe it would be a better idea to specify it. (with the @@loop attribute).
This has the obvious problem that you need to know a lot of details about the compiler to get the best performances, but this is the reasoning around that decision for now.