public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/50384] New: Copying a char array
@ 2011-09-13 14:50 marc.glisse at normalesup dot org
  2011-09-14  8:24 ` [Bug other/50384] " marc.glisse at normalesup dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: marc.glisse at normalesup dot org @ 2011-09-13 14:50 UTC (permalink / raw)
  To: gcc-bugs

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?


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-21  0:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-13 14:50 [Bug other/50384] New: Copying a char array marc.glisse at normalesup dot org
2011-09-14  8:24 ` [Bug other/50384] " marc.glisse at normalesup dot org
2012-01-28 20:34 ` [Bug middle-end/50384] Returning std::array is not optimal pinskia at gcc dot gnu.org
2012-01-28 20:57 ` marc.glisse at normalesup dot org
2021-07-21  0:45 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).