https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82705

            Bug ID: 82705
           Summary: Missing tail calls for large structs
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jmuizelaar at mozilla dot com
  Target Milestone: ---

The following code:

struct Foo {
   int o[16];
};

__attribute__((noinline))
Foo moo()
{
        return {0};
}

Foo goo()
{
        return moo();
}

with -O3 -fno-exceptions -fomit-frame-pointer compiles to:
moo():
  pxor xmm0, xmm0
  mov rax, rdi
  movups XMMWORD PTR [rdi], xmm0
  movups XMMWORD PTR [rdi+16], xmm0
  movups XMMWORD PTR [rdi+32], xmm0
  movups XMMWORD PTR [rdi+48], xmm0
  ret
goo():
  sub rsp, 8
  call moo()
  add rsp, 8
  mov rax, rdi
  ret

goo could just be:

goo():
  jmp moo

Also it seems like the "sub rsp, 8" and "add rsp, 8" are extraneous

Reply via email to