3 ms·
You really wouldn't. We tried many approaches, including computed goto, but none of them were able to generate satisfactory code when compared with tail calls:
by haberman 6y ago
You really wouldn't. We tried many approaches, including computed goto, but none of them were able to generate satisfactory code when compared with tail calls: https://gcc.gnu.org/pipermail/gcc/2021-April/235891.html https://gcc.gnu.org/pipermail/gcc/2021-April/235891.html
Also, it is not an implicit optimization when "musttail" support is available in the compiler.
- slver 6y agoTailcall optimization is compiled as a JMP, so is goto, so I'm curious where would the difference come from?
- haberman 6y agoThe tail call design gives more control over register allocation, and gets the compiler to generate better code by putting fast paths and slow paths in separate functions. I tried to explain this in the article and in my link upthread.