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

            Bug ID: 83031
           Summary: Tail call optimization not used in cases when first
                    part of the result is returned from function
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

Following code:

struct ts {int a, b; };
ts foo();

int testing1() {
    return foo().a;
}


Produces suboptimal assembly:
testing1():
        sub     rsp, 8
        call    foo()
        add     rsp, 8
        ret

More optimal would be the following assembly:
testing1():
        jmp     foo() <== `a` is already in eax

Reply via email to