Bug 44483 - [4.6 regression] gcc consumes all available memory when optimizing
Summary: [4.6 regression] gcc consumes all available memory when optimizing
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Sebastian Pop
URL:
Keywords: memory-hog
Depends on:
Blocks:
 
Reported: 2010-06-09 17:41 UTC by Martin Reinecke
Modified: 2010-06-11 18:30 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work: 4.5.0
Known to fail: 4.6.0
Last reconfirmed: 2010-06-09 22:13:10


Attachments
test case (24.64 KB, application/gzip)
2010-06-09 17:42 UTC, Martin Reinecke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Reinecke 2010-06-09 17:41:47 UTC
When compiling the attached testcase, current trunk gcc uses all available memory on my system (4GB) and then swaps until I interrupt the process. This only happens with -O3; using -O2 works as expected.
gcc 4.5 comiles the file as expected with -O3.

/scratch/tmp/devel2/build.linux_gcc/libcfitsio>gcc -c -O3 -v checksum.i
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/afs/mpa/data/martin/ugcc/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /scratch/martin/gcc/configure --disable-bootstrap --enable-gold --enable-plugins --prefix=/afs/mpa/data/martin/ugcc --with-ppl=/afs/mpa/data/martin/numlibs64 --with-cloog=/afs/mpa/data/martin/numlibs64 --with-libelf=/afs/mpa/data/martin/numlibs64 --enable-languages=c++,fortran --enable-target=all --enable-checking=release
Thread model: posix
gcc version 4.6.0 20100609 (experimental) [trunk revision 160476] (GCC) 
COLLECT_GCC_OPTIONS='-c' '-O3' '-v' '-mtune=generic' '-march=x86-64'
 /afs/mpa/data/martin/ugcc/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/cc1 -fpreprocessed checksum.i -quiet -dumpbase checksum.i -mtune=generic -march=x86-64 -auxbase checksum -O3 -version -o /tmp/ccibJbLw.s
GNU C (GCC) version 4.6.0 20100609 (experimental) [trunk revision 160476] (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.2, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
warning: GMP header version 4.3.2 differs from library version 4.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.6.0 20100609 (experimental) [trunk revision 160476] (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.2, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
warning: GMP header version 4.3.2 differs from library version 4.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: f4e23293da4cc17049a858a32373cf07
^C
/scratch/tmp/devel2/build.linux_gcc/libcfitsio>
Comment 1 Martin Reinecke 2010-06-09 17:42:43 UTC
Created attachment 20879 [details]
test case
Comment 2 Falk Hueffner 2010-06-09 19:11:01 UTC
Confirmed, seems to be in if-conv. Here's a smaller test case:

int ffesum (void) {
  int ch[4], ii, jj, kk;
  char asc[32];

  for (ii = 0; ii < 4; ii++)
    {
      for (jj = 0; jj < 4; jj++)
	ch[jj] = ii;
      for (kk = 0; kk < 13; kk++)
	for (jj = 0; jj < 4; jj += 2)
	  if ((unsigned char) ch[jj] || (unsigned char) ch[jj + 1])
	    ch[jj]++;
      for (jj = 0; jj < 4; jj++)
	asc[4 * jj + ii] = ch[jj];
    }
  return asc[0];
}
Comment 3 H.J. Lu 2010-06-09 22:06:42 UTC
It is caused by revision 159886:

http://gcc.gnu.org/ml/gcc-cvs/2010-05/msg00942.html
Comment 4 Sebastian Pop 2010-06-09 22:13:10 UTC
Mine.
Comment 5 Sebastian Pop 2010-06-10 22:59:48 UTC
Patch http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01155.html
Comment 6 Sebastian Pop 2010-06-11 18:28:40 UTC
Subject: Bug 44483

Author: spop
Date: Fri Jun 11 18:28:17 2010
New Revision: 160625

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160625
Log:
Fix PR44483: incrementally gimplify BB predicates to avoid redundant computations.

2010-06-11  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/44483
	* tree-if-conv.c (bb_predicate_s): New struct.
	(bb_predicate_p): New.
	(bb_has_predicate): New.
	(bb_predicate): New.
	(set_bb_predicate): New.
	(bb_predicate_gimplified_stmts): New.
	(set_bb_predicate_gimplified_stmts): New.
	(add_bb_predicate_gimplified_stmts): New.
	(init_bb_predicate): New.
	(free_bb_predicate): New.
	(is_predicated): Use bb_predicate.
	(add_to_predicate_list): Use bb_predicate and set_bb_predicate.
	(predicate_bbs): Same.  Gimplify the condition of the basic blocks
	before processing their successors.
	(clean_predicate_lists): Removed.
	(find_phi_replacement_condition): Use bb_predicate.
	(process_phi_nodes): Renamed ifconvert_phi_nodes.  Avoid useless
	computations.
	(insert_gimplified_predicates): New.
	(combine_blocks): Call insert_gimplified_predicates.
	(tree_if_conversion): Call free_bb_predicate instead of
	clean_predicate_lists.

	* gcc.dg/tree-ssa/pr44483.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr44483.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-if-conv.c

Comment 7 Sebastian Pop 2010-06-11 18:30:04 UTC
Fixed.