This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/50384] New: Copying a char array


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50384

             Bug #: 50384
           Summary: Copying a char array
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: marc.glisse@normalesup.org


#include <array>
typedef std::array<char,7> X;
X f(X,X);
X g(X a,X b){return f(a,b);}

I compiled this code on x86_64 with g++ -std=c++0x -Ofast and got:

_Z1gSt5arrayIcLm7EES0_:
.LFB837:
    .cfi_startproc
    pushq    %rbx
    .cfi_def_cfa_offset 16
    subq    $48, %rsp
    .cfi_def_cfa_offset 64
    .cfi_offset 3, -16
    call    _Z1fSt5arrayIcLm7EES0_
    movzbl    %ah, %edx
    movb    %al, (%rsp)
    movb    %dl, 1(%rsp)
    movq    %rax, %rdx
    shrq    $16, %rdx
    movb    %dl, 2(%rsp)
    movq    %rax, %rdx
    shrq    $24, %rdx
    movb    %dl, 3(%rsp)
    movq    %rax, %rdx
    movl    (%rsp), %ecx
    shrq    $32, %rdx
    movb    %dl, 4(%rsp)
    movq    %rax, %rdx
    shrq    $40, %rdx
    movl    %ecx, %esi
    movzbl    %cl, %ebx
    movb    %dl, 5(%rsp)
    movl    %ecx, %edx
    movzwl    4(%rsp), %edi
    shrl    $16, %edx
    movzbl    %ch, %ecx
    shrl    $24, %esi
    movzbl    %dl, %edx
    movb    %cl, %bh
    movzbl    %sil, %esi
    salq    $16, %rdx
    salq    $24, %rsi
    movabsq    $-1095216660481, %rcx
    orq    %rbx, %rdx
    movq    %rdi, %rbx
    addq    $48, %rsp
    .cfi_def_cfa_offset 16
    orq    %rsi, %rdx
    movzbl    %dil, %esi
    salq    $32, %rsi
    andq    %rcx, %rdx
    movzbl    %bh, %ecx
    orq    %rsi, %rdx
    movabsq    $-280375465082881, %rsi
    salq    $40, %rcx
    andq    %rsi, %rdx
    orq    %rcx, %rdx
    movabsq    $71776119061217280, %rcx
    andq    %rcx, %rax
    movabsq    $-71776119061217281, %rcx
    andq    %rcx, %rdx
    orq    %rax, %rdx
    movq    %rdx, %rax
    popq    %rbx
    .cfi_def_cfa_offset 8
    ret
    .cfi_endproc

Ideally I would have liked a single jmp, but in any case this seems a bit
long... (the attribute((aligned)) in versions <= 4.2 did help)
Is that the best that can legally be done without alignment information?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]