[Bug c++/40460] Enormous memory usage during compilation with -O2 or -O3 optimizations.

2009-06-16 Thread rguenth at gcc dot gnu dot org


--- Comment #1 from rguenth at gcc dot gnu dot org  2009-06-16 13:09 ---
Confirmed.  Exponential memory use at -O2:

26 factors: 650MB
27 factors:1255MB
28 factors:2459MB

oops... ;)

26 factor testcase:

#include iostream

int main() 
{
  for (int i=0;i1;++i)
std::cout  (i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i*i);

  return 0;
}


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||rguenth at gcc dot gnu dot
   ||org
 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Keywords||memory-hog
  Known to fail||4.4.0
   Last reconfirmed|-00-00 00:00:00 |2009-06-16 13:09:08
   date||


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



[Bug c++/40460] Enormous memory usage during compilation with -O2 or -O3 optimizations.

2009-06-16 Thread rguenth at gcc dot gnu dot org


--- Comment #2 from rguenth at gcc dot gnu dot org  2009-06-16 13:20 ---
Oh, this is yet another case of SCEV going crazy..., called from complete
unrolling in this case.

0x0118bcc5 in chrec_fold_multiply (type=0x77ee8540, 
op0=0x7273a500, op1=0x77f14b40)
at /space/rguenther/src/svn/trunk/gcc/tree-chrec.c:401
401   return build_polynomial_chrec 
Value returned is $14 = (union tree_node *) 0x7fffe7099780
(gdb) call debug_generic_expr ($14)
{{D.21167_5 * 512, +, D.21167_5 * 1024}_1, +, {D.21167_5 * 1024, +,
D.21167_5 * 2048}_1}_1, +, {{D.21167_5 * 1024, +, D.21167_5 * 2048}_1, +,
{D.21167_5 * 2048, +, D.21167_5 * 4096}_1}_1}_1, +, {{{D.21167_5 * 1024, +,
D.21167_5 * 2048}_1, +, {D.21167_5 * 2048, +, D.21167_5 * 4096}_1}_1, +,
{{D.21167_5 * 2048, +, D.21167_5 * 4096}_1, +, {D.21167_5 * 4096, +, D.21167_5
* 8192}_1}_1}_1}_1, +, D.21167_5 * 1024, +, D.21167_5 * 2048}_1, +,
{D.21167_5 * 2048, +, D.21167_5 * 4096}_1}_1, +, {{D.21167_5 * 2048, +,
D.21167_5 * 4096}_1, +, {D.21167_5 * 4096, +, D.21167_5 * 8192}_1}_1}_1, +,
{{{D.21167_5 * 2048, +, D.21167_5 * 4096}_1, +, {D.21167_5 * 4096, +, D.21167_5
* 8192}_1}_1, +, {{D.21167_5 * 4096, +, D.21167_5 * 8192}_1, +, {D.21167_5 *
8192, +, D.21167_5 * 16384}_1}_1}_1}_1}_1, +, {D.21167_5 * 1024, +,
D.21167_5 * 2048}_1, +, {D.21167_5 * 2048, +, D.21167_5 * 4096}_1}_1, +,
{{D.21167_5 * 2048, +, D.21167_5 * 4096}_1, +, {D.21167_5 * 4096, +, D.21167_5
* 8192}_1}_1}_1, +, {{{D.21167_5 * 2048, +, D.21167_5 * 4096}_1, +, {D.21167_5
* 4096, +, D.21167_5 * 8192}_1}_1, +, {{D.21167_5 * 4096, +, D.21167_5 *
8192}_1, +, {D.21167_5 * 8192, +, D.21167_5 * 16384}_1}_1}_1}_1, +,
D.21167_5 * 2048, +, D.21167_5 * 4096}_1, +, {D.21167_5 * 4096, +,
D.21167_5 * 8192}_1}_1, +, {{D.21167_5 * 4096, +, D.21167_5 * 8192}_1, +,
{D.21167_5 * 8192, +, D.21167_5 * 16384}_1}_1}_1, +, {{{D.21167_5 * 4096, +,
D.21167_5 * 8192}_1, +, {D.21167_5 * 8192, +, D.21167_5 * 16384}_1}_1, +,
{{D.21167_5 * 8192, +, D.21167_5 * 16384}_1, +, {D.21167_5 * 16384, +,
D.21167_5 * 32768}_1}_1}_1}_1}_1}_1

I will have a look.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||spop at gcc dot gnu dot org
 AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
   |dot org |org
 Status|NEW |ASSIGNED
   Last reconfirmed|2009-06-16 13:09:08 |2009-06-16 13:20:02
   date||


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



[Bug c++/40460] Enormous memory usage during compilation with -O2 or -O3 optimizations.

2009-06-16 Thread rguenth at gcc dot gnu dot org


--- Comment #3 from rguenth at gcc dot gnu dot org  2009-06-16 13:42 ---
chrec_fold_multiply_poly_poly is exponential...

Why does {0, +, 1}_1 * {0, +, 1}_1 yield {0, +, {1, +, 2}_1}_1?  Shouldn't
we just punt if we generate exponential chrecs?  Will we ever be able to
do something reasonable with them?

In this testcase the args to chrec_fold_multiply_poly_poly grow
exponentially.


-- 


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



[Bug c++/40460] Enormous memory usage during compilation with -O2 or -O3 optimizations.

2009-06-16 Thread rguenth at gcc dot gnu dot org


--- Comment #4 from rguenth at gcc dot gnu dot org  2009-06-16 14:01 ---
It looks like the fix is

Index: gcc/tree-chrec.h
===
--- gcc/tree-chrec.h(revision 148523)
+++ gcc/tree-chrec.h(working copy)
@@ -132,7 +132,8 @@ build_polynomial_chrec (unsigned loop_nu
   || right == chrec_dont_know)
 return chrec_dont_know;

-  if (no_evolution_in_loop_p (left, loop_num, val)  !val)
+  if (!no_evolution_in_loop_p (left, loop_num, val)
+  || !val)
 return chrec_dont_know;

   /* Pointer types should occur only on the left hand side, i.e. in


to make its result consistent for constant vs. non-constant chrecs.

{0, +, {1, +, 2}_1}_1 * {0, +, 1}_1  -  scev_not_known

but

{0, +, {D.21167_5, +, D.21167_5 * 2}_1}_1 * {0, +, 1}_1
  -  {0, +, {{D.21167_5, +, D.21167_5 * 2}_1, +, {D.21167_5 * 2, +, D.21167_5
* 4}_1}_1}_1


-- 


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