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

            Bug ID: 82935
           Summary: Unnecessary "sub rsp, 8", "call" and "add rsp, 8"
                    instructions
           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

typedef struct array_ {
    int data[10202023];
} array;

void assign(array* a1, array* a2) {
    *a1 = *a2;
}


Generates assembly:
assign:
        sub     rsp, 8    <==== Not required
        mov     edx, 40808092
        call    memcpy    <==== jmp ?
        add     rsp, 8    <==== Not required
        ret



Clang generates much more compact assembly:
assign:                                 # @assign
        mov     edx, 40808092
        jmp     memcpy                  # TAILCALL

Reply via email to