This is the mail archive of the 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 c++/29375] New: gcc4.0.3 produces code that copies a structure twice

Using built-in specs.
Target: x86_64-redhat-linux-gnu
Configured with: ../gcc-4.0.3/configure x86_64-redhat-linux-gnu
--with-as=/pixar/d2/sets/tools-03/bin/as --prefix=/pixar/d2/sets/tools-03
--exec-prefix=/pixar/d2/sets/tools-03 --bindir=/pixar/d2/sets/tools-03/bin
--sbindir=/pixar/d2/sets/tools-03/sbin --sysconfdir=/pixar/d2/sets/tools-03/etc
--mandir=/pixar/d2/sets/tools-03/man --infodir=/pixar/d2/sets/tools-03/info
--enable-version-specific-runtime-libs --enable-symvers
--enable-languages=c++,objc,f95 --enable-threads=posix --enable-shared
Thread model: posix
gcc version 4.0.3

struct Big {
    char data[1024];

void ByValue(Big);

void MakeACopy() {
    Big stuff;

The relevant assembly code, when compiled as:  g++ -O2 -S prog.cpp

.globl _Z9MakeACopyv
        .type   _Z9MakeACopyv, @function
        pushq   %rbx
        movl    $1024, %edx
        subq    $3072, %rsp
        leaq    2048(%rsp), %rbx
        leaq    1024(%rsp), %rsi
        movq    %rbx, %rdi
        call    memcpy
        movq    %rbx, %rsi
        movq    %rsp, %rdi
        movl    $1024, %edx
        call    memcpy
        call    _Z7ByValue3Big
        addq    $3072, %rsp
        popq    %rbx

I'm far from an export, but it sure looks to me like memcpy is being called
twice to copy the data!
This is supported by the fact that gcc3.3.2 only emits code to copy it once,
and that code runs twice as fast.

Also, gcc3.3.2 inlines the memcpy, while gcc4.0.3 does not.  I assume that's a
regression as well?
If not, what's the best option to tell gcc4.0.3 to inline the copy?

           Summary: gcc4.0.3 produces code that copies a structure twice
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: deb at pixar dot com

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