balaji.i...@gtri.gatech.edu wrote:
Hello Everyone,
        I am creating a benchmark, where I have a following code:

    x1 = a * b
    x2 = x1 * a;
    x3 = x1* x2;
    x4 = x2 * x3;
    x5 = x3 * x4;
    x6 = x5 * x6;
. . . . . .
   x1000 = x999 * x998;



When I do this, and compile using -O3/-O2/-O1, the compiler freezes. Am I doing anything wrong?
GCC Version: 4.2.1
Platform: x86_64 (in macOS Snow Leopard).

I also tested this on a i386 (Red Hat 4.3.2-7) machine with gcc 4.3.2 and I had 
the same response.

Please CC me in the response since I m not a subscribed member of this mailing list.

I have no real idea on this particular issue, but I did empirically observe that on some programs (for me, it was the MELT generated C code on my MELT [1] branch eg before rev 154917) the register allocator (or some optimizing passes) might have in practice an O(n^2) behavior, and might need a lot of memory

I would suggest:

* trying a very recent gcc (that you probably should build from its released source code), at least gcc 4.4.3 http://gcc.gnu.org/gcc-4.4/ or perhaps a gcc 4.5 snapshot.

* reducing the number of variables (to e.g. 300 or 500 instead of 1000).

* compiling first with -O1

* compiling with -ftime-report

* observe the cpu time and memory consumption of the compilation, eg by running 
the top utility in a separate terminal.

So try first to reduce the number of variables (perhaps even to 200) and to 
compile with
   gcc-4.4 -O1 -ftime-report -v -c benchbalaji.c

I believe that recent GCC (ie 4.4 at least) had serious progress both on register allocation and on some optimization passes, so they probably should work better on your [pathological] case.

Regards.

Note [1]: MELT is a lisp like dialect -translated into C- for coding GCC passes in plugins, and it used to generate huge initialization routines. This is no more the case since a few weeks (because there is no more huge routines, only several big ones), MELT can be reasonably compiled on a desktop even with optimization like -O2.

--
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***

Reply via email to