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

            Bug ID: 59062
           Summary: poor code generated at -Os (affecting all gcc
                    versions): 10+ sec vs. 1 sec at -O0
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk (as well as 4.6, 4.7, and 4.8) produces poor code for the
 following testcase on x86_64-linux-gnu at -Os in both 32-bit and 64-bit modes. 

The produced code has the same or very similar size. 

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--enable-checking=release --with-gmp=/usr/local/gcc-trunk
--with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk
--with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20131109 (experimental) [trunk revision 204611] (GCC) 
$ 
$ gcc-trunk -O0 small.c       
$ time a.out
1.02user 0.00system 0:01.05elapsed 97%CPU (0avgtext+0avgdata 1584maxresident)k
0inputs+0outputs (0major+142minor)pagefaults 0swaps
$ gcc-trunk -O1 small.c
$ time a.out
0.68user 0.00system 0:00.68elapsed 98%CPU (0avgtext+0avgdata 1568maxresident)k
0inputs+0outputs (0major+140minor)pagefaults 0swaps
$ gcc-trunk -Os small.c
$ time a.out
12.84user 0.00system 0:12.86elapsed 99%CPU (0avgtext+0avgdata 1568maxresident)k
0inputs+0outputs (0major+140minor)pagefaults 0swaps
$ 


--------------------------------


#pragma pack(1)
struct 
{
  int f0:23;
  unsigned int f1:23;
  unsigned int f2:7;
} b, c; 

unsigned int a; 

int 
main ()
{
  for (; a != 14; a += 9)
    c = b; 
  return 0;
}

Reply via email to