This is the mail archive of the gcc-help@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]

g++ Long compile times


The program below is not very smart and repeats a pattern over and over (it is a simplification of a program that is automatically generated by a modeling language). It seems that the compiler is also not very smart and is repeating some calculations over and over.

When I use g++ to compile the program with
    EXTRA_CLASS_OBJECTS=0
the compile time is about 3 seconds. When
    EXTRA_CLASS_OBJECTS=1
the compile time is about 12 seconds.
(See the end of this message for the output of gcc -v on my system.)

The attached file gcc_slow.sh is a bash script that can be used to test this
on any system. If you execute
     ./gcc_slow.sh
you will get a help message that describes how it works.

Are there compile time options for gcc that can significantly reduce the g++
compile for EXTRA_CLASS_OBJECTS=1 case in the example program below ?
-------------------------------------------------------------------------

# include<cstdlib>
class mydouble {
public:
      double value_;
      mydouble&  operator =(double right);
      mydouble operator +(double right);

# if EXTRA_CLASS_OBJECTS
      size_t id_;
      mydouble(void);
      mydouble(size_t x);
      mydouble(int x);
      mydouble(double x);
# endif
};
mydouble mysum(void)
{
      mydouble x_0;
      x_0 = 0;
      mydouble x_1;
      x_1 = x_0 + 1.;
      mydouble x_2;
     ...
      mydouble x_7999;
      x_7999 = x_7998 + 7999.;
      return x_7999;
}
-------------------------------------------------------------------------
Using built-in specs.
Target: i686-pc-cygwin
Configured with: /gnu/gcc/releases/packaging/4.3.4-3/gcc4-4.3.4-3/src/gcc-4.3.4/configure --srcdir=/gnu/gcc/releases/packaging/4.3.4-3/gcc4-4.3.4-3/src/gcc-4.3.4 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --infodir=/usr/share/info --mandir=/usr/share/man --datadir=/usr/share --infodir=/usr/share/info --mandir=/usr/share/man -v --with-gmp=/usr --with-mpfr=/usr --enable-bootstrap --enable-version-specific-runtime-libs --with-slibdir=/usr/bin --libexecdir=/usr/lib --enable-static --enable-shared --enable-shared-libgcc --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2 --disable-sjlj-exceptions --enable-languages=ada,c,c++,fortran,java,objc,obj-c++ --disable-symvers --enable-libjava --program-suffix=-4 --enable-libgomp --enable-libssp --enable-libada --enable-threads=posix --with-arch=i686 --with-tune=generic --enable-libgcj-sublibs CC=gcc-4 CXX=g++-4 CC_FOR_TARGET=gcc-4 CXX_FOR_TARGET=g++-4 GNATMAKE_FOR_TARGET=gnatmake GNATBIND_FOR_TARGET=gnatbind AS=/opt/gcc-tools/bin/as.exe AS_FOR_TARGET=/opt/gcc-tools/bin/as.exe LD=/opt/gcc-tools/bin/ld.exe LD_FOR_TARGET=/opt/gcc-tools/bin/ld.exe --with-ecj-jar=/usr/share/java/ecj.jar
Thread model: posix
gcc version 4.3.4 20090804 (release) 1 (GCC)

Attachment: gcc_slow.sh
Description: Text document


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