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



             Bug #: 57051

           Summary: Optimization regression in 4.8.0 from 4.7.2

    Classification: Unclassified

           Product: gcc

           Version: unknown

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: tony.howard-co84u...@yopmail.com





The problem can be exhibited using the following snippet of code:



/* begin */

int total = 0;





inline void foo(int bar)

{

   total += bar*10;

}



void hello()

{

   for(int i = 0; i < 10; ++i)

   {

      foo(i);

   }

}

/* end */



With the option -O3,

gcc 4.7.2 and previous versions produce the following assembly code:

hello():

    addl    $450, total(%rip)

    ret



gcc 4.8.0 fails to optimize the code:

hello():

    movdqa    .LC0(%rip), %xmm0

    movdqa    %xmm0, %xmm2

    psrldq    $8, %xmm2

    paddd    %xmm2, %xmm0

    movdqa    %xmm0, %xmm3

    psrldq    $4, %xmm3

    paddd    %xmm3, %xmm0

    movdqa    %xmm0, %xmm4

    movd    %xmm4, -12(%rsp)

    movl    -12(%rsp), %eax

    addl    total(%rip), %eax

    addl    $170, %eax

    movl    %eax, total(%rip)

    ret





The results can be easily reproduced using http://gcc.godbolt.org/



The 4.7.2's configure options are:

Target: x86_64-linux-gnu



Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro

4.7.2-11precise2' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs

--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr

--program-suffix=-4.7 --enable-shared --enable-linker-build-id

--with-system-zlib --libexecdir=/usr/lib --without-included-gettext

--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7

--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu

--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object

--enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686

--with-abi=m64 --with-multilib-list=m32,m64 --with-tune=generic

--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu

--target=x86_64-linux-gnu



The 4.8.0's configure options are:

Target: x86_64-linux-gnu



Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro

4.8.0-3ubuntu3~12.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs

--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr

--program-suffix=-4.8 --enable-shared --enable-linker-build-id

--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix

--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls

--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug

--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin

--with-system-zlib --enable-objc-gc --enable-multiarch --disable-werror

--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64

--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu

--host=x86_64-linux-gnu --target=x86_64-linux-gnu



The problem is not linked to Linaro or Ubuntu patches as it can be reproduced

as well on a stock version of gcc 4.8.0

Reply via email to