Please delete this thread, I have found the solution. Sorry for the inconvenience
Printable View
Please delete this thread, I have found the solution. Sorry for the inconvenience
It already looks like it is capable of tail recursion elimination.
Indeed, gcc seems to think so.
Closer inspection of the optimised code shows that a jump is used where there should be a call.Code:$ gcc -S bar.c
$ grep helper bar.s
.globl count_helper
.type count_helper, @function
count_helper:
call count_helper
.size count_helper, .-count_helper
$ gcc -S -O2 bar.c
$ grep helper bar.s
.globl count_helper
.type count_helper, @function
count_helper:
.size count_helper, .-count_helper