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

            Bug ID: 91515
           Summary: missed optimization: no tailcall for types of class
                    MEMORY
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: no...@turm-lahnstein.de
  Target Milestone: ---

Produced assembler (-O2) for

   struct Vec3{
    double x, y, z;
   };

   struct Vec3 create(void);

   struct Vec3 use(){
    return create();
   }

looks as follows (live: https://godbolt.org/z/v-HjX0):

    use:
        pushq   %r12
        movq    %rdi, %r12
        call    create
        movq    %r12, %rax
        popq    %r12
        ret

Hower, I think that under System V AMD64 - ABI, the tailcall optimization:

    use:
        jmp    create

as create will move  %rdi-value to %rax anyway.

Reply via email to