From bb5dcf93599876def7c492ee66e9d0a273bd82e5 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Wed, 17 Jun 2009 12:00:40 +0000 Subject: [PATCH] re PR middle-end/40460 (Enormous memory usage during compilation with -O2 or -O3 optimizations.) 2009-06-17 Richard Guenther PR middle-end/40460 * tree-chrec.h (build_polynomial_chrec): If we cannot determine if there is no evolution of left in the loop bail out. * tree-chrec.c (chrec_fold_multiply_poly_poly): CSE one chrec_fold_multiply. * g++.dg/torture/pr40460.C: New testcase. From-SVN: r148603 --- gcc/ChangeLog | 8 ++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr40460.C | 9 +++++++++ gcc/tree-chrec.c | 10 +++++----- gcc/tree-chrec.h | 3 ++- 5 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr40460.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 546a2051553f..d4402d07d516 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2009-06-17 Richard Guenther + + PR middle-end/40460 + * tree-chrec.h (build_polynomial_chrec): If we cannot determine + if there is no evolution of left in the loop bail out. + * tree-chrec.c (chrec_fold_multiply_poly_poly): CSE one + chrec_fold_multiply. + 2009-06-11 Uros Bizjak Backport from mainline: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3c0a7af86c07..cb1d8a0fb7c3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-06-17 Richard Guenther + + PR middle-end/40460 + * g++.dg/torture/pr40460.C: New testcase. + 2009-06-08 Jakub Jelinek PR c++/40373 diff --git a/gcc/testsuite/g++.dg/torture/pr40460.C b/gcc/testsuite/g++.dg/torture/pr40460.C new file mode 100644 index 000000000000..1d54df72b573 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr40460.C @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void bar(int); +void foo(void) +{ + for (int i = 0; i<1; ++i) + bar (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*i*i*i*i*i*i*i); +} + diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 1435201a9511..ccc1dcfa724f 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -219,16 +219,16 @@ chrec_fold_multiply_poly_poly (tree type, /* "a*c". */ t0 = chrec_fold_multiply (type, CHREC_LEFT (poly0), CHREC_LEFT (poly1)); - /* "a*d + b*c + b*d". */ + /* "a*d + b*c". */ t1 = chrec_fold_multiply (type, CHREC_LEFT (poly0), CHREC_RIGHT (poly1)); t1 = chrec_fold_plus (type, t1, chrec_fold_multiply (type, CHREC_RIGHT (poly0), CHREC_LEFT (poly1))); - t1 = chrec_fold_plus (type, t1, chrec_fold_multiply (type, - CHREC_RIGHT (poly0), - CHREC_RIGHT (poly1))); - /* "2*b*d". */ + /* "b*d". */ t2 = chrec_fold_multiply (type, CHREC_RIGHT (poly0), CHREC_RIGHT (poly1)); + /* "a*d + b*c + b*d". */ + t1 = chrec_fold_plus (type, t1, t2); + /* "2*b*d". */ t2 = chrec_fold_multiply (type, SCALAR_FLOAT_TYPE_P (type) ? build_real (type, dconst2) : build_int_cst (type, 2), t2); diff --git a/gcc/tree-chrec.h b/gcc/tree-chrec.h index c908ec5c66b4..37a54bee114d 100644 --- a/gcc/tree-chrec.h +++ b/gcc/tree-chrec.h @@ -129,7 +129,8 @@ build_polynomial_chrec (unsigned loop_num, || 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 -- 2.47.2