https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101769
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:4d562591018a51f155a2e5d8b9f3e5860111a327 commit r12-2721-g4d562591018a51f155a2e5d8b9f3e5860111a327 Author: Richard Biener <rguent...@suse.de> Date: Wed Aug 4 09:22:51 2021 +0200 tree-optimization/101769 - tail recursion creates possibly infinite loop This makes tail recursion optimization produce a loop structure manually rather than relying on loop fixup. That also allows the loop to be marked as finite (it would eventually blow the stack if it were not). 2021-08-04 Richard Biener <rguent...@suse.de> PR tree-optimization/101769 * tree-tailcall.c (eliminate_tail_call): Add the created loop for the first recursion and return it via the new output parameter. (optimize_tail_call): Pass through new output param. (tree_optimize_tail_calls_1): After creating all latches, add the created loop to the loop tree. Do not mark loops for fixup. * g++.dg/tree-ssa/pr101769.C: New testcase.