From: Richard Biener Date: Mon, 11 Nov 2019 16:07:54 +0000 (+0000) Subject: backport: re PR tree-optimization/90930 (Excessive memory consumption) X-Git-Tag: releases/gcc-9.3.0~396 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=949b1f43b4acc3ba527879a01acbcee67d7c3481;p=thirdparty%2Fgcc.git backport: re PR tree-optimization/90930 (Excessive memory consumption) 2019-11-11 Richard Biener Backport from mainline 2019-06-25 Richard Biener PR tree-optimization/90930 * tree-ssa-reassoc.c (reassociate_bb): Only rewrite expression into parallel form in the last pass instance. * gcc.dg/tree-ssa/reassoc-24.c: Adjust. * gcc.dg/tree-ssa/reassoc-25.c: Likewise. From-SVN: r278059 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8552b2a072fe..c0ef3795017f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2019-11-11 Richard Biener + + Backport from mainline + 2019-06-25 Richard Biener + + PR tree-optimization/90930 + * tree-ssa-reassoc.c (reassociate_bb): Only rewrite expression + into parallel form in the last pass instance. + 2019-11-11 H.J. Lu Backport from trunk: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 304b40517ddb..f77cdb49cda7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2019-11-11 Richard Biener + + Backport from mainline + 2019-06-25 Richard Biener + + PR tree-optimization/90930 + * gcc.dg/tree-ssa/reassoc-24.c: Adjust. + * gcc.dg/tree-ssa/reassoc-25.c: Likewise. + 2019-11-10 Thomas Koenig Backport from trunk diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-24.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-24.c index 4503cd740095..c320d1cb71b1 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-24.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-24.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 --param tree-reassoc-width=2 -fdump-tree-reassoc1" } */ +/* { dg-options "-O2 --param tree-reassoc-width=2 -fdump-tree-reassoc2" } */ unsigned int foo (void) @@ -21,4 +21,4 @@ foo (void) /* Verify there are two pairs of __asm__ statements with no intervening stmts. */ -/* { dg-final { scan-tree-dump-times "__asm__\[^;\n]*;\n *__asm__" 2 "reassoc1"} } */ +/* { dg-final { scan-tree-dump-times "__asm__\[^;\n]*;\n *__asm__" 2 "reassoc2"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-25.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-25.c index 553736bc391e..dbb02683778b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-25.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-25.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 --param tree-reassoc-width=3 -fdump-tree-reassoc1-details" } */ +/* { dg-options "-O2 --param tree-reassoc-width=3 -fdump-tree-reassoc2-details" } */ unsigned int foo (int a, int b, int c, int d) @@ -15,4 +15,4 @@ foo (int a, int b, int c, int d) } /* Verify reassociation width was chosen to be 2. */ -/* { dg-final { scan-tree-dump-times "Width = 2" 1 "reassoc1"} } */ +/* { dg-final { scan-tree-dump-times "Width = 2" 1 "reassoc2"} } */ diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 7161c4c36c38..6794fbde29e6 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -6013,12 +6013,7 @@ reassociate_bb (basic_block bb) { machine_mode mode = TYPE_MODE (TREE_TYPE (lhs)); int ops_num = ops.length (); - int width = get_reassociation_width (ops_num, rhs_code, mode); - - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, - "Width = %d was chosen for reassociation\n", width); - + int width; /* For binary bit operations, if there are at least 3 operands and the last last operand in OPS is a constant, @@ -6032,10 +6027,21 @@ reassociate_bb (basic_block bb) && TREE_CODE (ops.last ()->op) == INTEGER_CST) std::swap (*ops[0], *ops[ops_num - 1]); - if (width > 1 - && ops.length () > 3) - rewrite_expr_tree_parallel (as_a (stmt), - width, ops); + /* Only rewrite the expression tree to parallel in the + last reassoc pass to avoid useless work back-and-forth + with initial linearization. */ + if (!reassoc_insert_powi_p + && ops.length () > 3 + && (width = get_reassociation_width (ops_num, rhs_code, + mode)) > 1) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, + "Width = %d was chosen for reassociation\n", + width); + rewrite_expr_tree_parallel (as_a (stmt), + width, ops); + } else { /* When there are three operands left, we want