This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/71761] missing tailcall optimization
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 04 Jul 2016 20:35:53 +0000
- Subject: [Bug tree-optimization/71761] missing tailcall optimization
- Auto-submitted: auto-generated
- References: <bug-71761-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71761
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
For clang, this seems based on size: up to size 16 they get jmp, starting from
17 they get a call.
For gcc, we give up on anything more complicated than a "register":
/* If the LHS of our call is not just a simple register, we can't
transform this into a tail or sibling call. This situation happens,
in (e.g.) "*p = foo()" where foo returns a struct. In this case
we won't have a temporary here, but we need to carry out the side
effect anyway, so tailcall is impossible.
??? In some situations (when the struct is returned in memory via
invisible argument) we could deal with this, e.g. by passing 'p'
itself as that argument to foo, but it's too early to do this here,
and expand_call() will not handle it anyway. If it ever can, then
we need to revisit this here, to allow that situation. */
if (ass_var && !is_gimple_reg (ass_var))
return;
The ??? comment is exactly your case.