https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66313
--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> --- Created attachment 41441 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41441&action=edit patch Patch I am testing, I finally managed to convince tailrecursion optimization to handle the case in gcc.dg/tree-ssa/tailrecursion-6.c after the fix to the folding. If testing goes well I'll commit this to trunk.