https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96051
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Last reconfirmed| |2021-12-05 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- /* If the code both contains VLAs and calls alloca, then we cannot reclaim the stack space allocated to the VLAs. */ And the stack restore in the case of VLA without the alloca just happens to be after the recusive function call to no_tco_with_vla_only. To do this optimization, we need to move the stack restore before the recusive function call and for that we need to make sure the VLA address never escapes. Anyways Confirmed.