-O2 -funroll-loops on LinuxPPC hangs gcc

Andy Ritger ritger@wolfram.com
Wed May 17 13:49:00 GMT 2000


The following bug was first noticed on a LinuxPPC installation on a 
PowerPC 750 (G3) with egcs-2.91.66, and has been reproduced on a LinuxPPC
installation on an iMac with gcc-2.95.2.


Given the following source file:
agrippa.wolfram.com [35] linux-ppc> cat test.c

#include <stdio.h>

int main ()
{
  long i = 1000000;  // <--- number of loops
  double c0, c1;
  
  c0 = c1 = 1.0;
  
  while (--i)
  {
    c0 += c0 * c0;
    c1 += c1 * c1;   // <--- this line
  }
  
  c0 = c0 + c1;
  printf ("c0 = %f\n", c0);
  
  return (0);
}


Compiled with: 

gcc -funroll-loops -O2 test.c -o test

works fine.

But if you comment out the line labeled "// <--- this line" and compile
using the same command as above, then cc1 quickly consumes all system
memory and eventually crashes the machine.

Compiling with either (leaving the "// <--- this line" commented out):

gcc -funroll-loops test.c -o test

or

gcc -O2 test.c -o test

works fine.

Varying the number of loops (e.g. changing "long i = 1000000;" to
"long i = 10;") or changing "c0 += c0 * c0;" to "c0 += c0;" does allow the
program to compile, but cc1 still takes an unusually long time and
requires an unusually large amount of memory in the process.

I'ved included the preprocessor output "test.i" generated with the 
original test.c with the line "// <--- this line" commented out and the
command line:

gcc -save-temps -funroll-loops -O2 test.c -o test

Using the -v option, I get:

agrippa.wolfram.com [63] linux-ppc> gcc -v -funroll-loops -O2 test.c -o
test
Reading specs from /usr/lib/gcc-lib/ppc-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
 /usr/lib/gcc-lib/ppc-redhat-linux/egcs-2.91.66/cpp -lang-c -v -undef
-D__GNUC__=2 -D__GNUC_MINOR__=91 -DPPC -D__ELF__ -Dunix -Dlinux -Dpowerpc
-D__PPC__ -D__ELF__ -D__unix__ -D__linux__ -D__powerpc__ -D__PPC -D__unix
-D__linux -D__powerpc -Asystem(unix) -Asystem(linux) -Acpu(powerpc)
-Amachine(powerpc) -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D_CALL_SYSV
-D_BIG_ENDIAN -D__BIG_ENDIAN__ -Amachine(bigendian) -D_ARCH_PPC -D__unix__
-D__linux__ -Dunix -Dlinux -Asystem(unix) -Asystem(linux) test.c
/tmp/ccA13n20.i
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (PowerPC
GNU/Linux)
#include "..." search starts here:
#include <...> search starts here:
 /usr/ppc-redhat-linux/include
 /usr/lib/gcc-lib/ppc-redhat-linux/egcs-2.91.66/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/ppc-redhat-linux/egcs-2.91.66/cc1 /tmp/ccA13n20.i -quiet
-dumpbase test.c -O2 -version -funroll-loops -o /tmp/ccqeuyX7.s
GNU C version egcs-2.91.66 19990314 (egcs-1.1.2 release)
(ppc-redhat-linux) compiled by GNU C version egcs-2.91.66 19990314
(egcs-1.1.2 release).


and at cc1 is where compilation halts.

Please let me know if there is any other information I can provide.

Thank you for all your efforts.

- Andy Ritger


More information about the Gcc-bugs mailing list