Bug 84552 - [7 Regression] Compile time hog w/ -O2 -floop-nest-optimize -fno-tree-copy-prop -fno-tree-fre -fno-tree-loop-ivcanon
Summary: [7 Regression] Compile time hog w/ -O2 -floop-nest-optimize -fno-tree-copy-pr...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 8.0
: P2 normal
Target Milestone: 7.5
Assignee: Richard Biener
URL:
Keywords: compile-time-hog
Depends on:
Blocks:
 
Reported: 2018-02-25 18:18 UTC by Arseny Solokha
Modified: 2019-03-26 11:20 UTC (History)
0 users

See Also:
Host:
Target: x86_64-linux-gnu
Build:
Known to work: 7.4.1, 8.0
Known to fail: 7.4.0
Last reconfirmed: 2018-02-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2018-02-25 18:18:29 UTC
gcc-8.0.0-alpha20180218 snapshot (r257797) takes indefinite time to compile the following snippet w/ -O2 -floop-nest-optimize -fno-tree-copy-prop -fno-tree-fre -fno-tree-loop-ivcanon:

int cx;

int
e6 (int pj, int xe)
{
  for (cx = 0; cx < 2; ++cx)
    while (xe < 1)
      {
        for (cx = 0; cx < 2; ++cx)
          pj *= 2;

        if (cx != 0)
          goto o3;

        ++xe;
      }

 o3:
  return pj;
}

% timeout 5 gcc-8.0.0-alpha20180218 -O2 -floop-nest-optimize -fno-tree-copy-prop -fno-tree-fre -fno-tree-loop-ivcanon -c v8gjilr7.c
zsh: exit 124   timeout 5 gcc-8.0.0-alpha20180218 -O2 -floop-nest-optimize -fno-tree-copy-pro

Two outstanding entries captured by perf top:

  61.24%  cc1       [.] degenerate_phi_result
  38.49%  cc1       [.] follow_copies_to_constant
Comment 1 Richard Biener 2018-02-27 13:49:31 UTC
Confirmed.
Comment 2 Richard Biener 2018-02-27 13:56:43 UTC
Probably related to us doing SCEV analysis w/o updating SSA form but follow_copies_to_constant and degenerate_phi_result not honoring that.
The following would fix this:

Index: gcc/tree-scalar-evolution.c
===================================================================
--- gcc/tree-scalar-evolution.c (revision 258030)
+++ gcc/tree-scalar-evolution.c (working copy)
@@ -280,6 +280,7 @@ along with GCC; see the file COPYING3.
 #include "params.h"
 #include "tree-ssa-propagate.h"
 #include "gimple-fold.h"
+#include "tree-into-ssa.h"
 
 static tree analyze_scalar_evolution_1 (struct loop *, tree);
 static tree analyze_scalar_evolution_for_address_of (struct loop *loop,
@@ -1545,7 +1546,9 @@ follow_copies_to_constant (tree var)
       gimple *def = SSA_NAME_DEF_STMT (res);
       if (gphi *phi = dyn_cast <gphi *> (def))
        {
-         if (tree rhs = degenerate_phi_result (phi))
+         if (name_registered_for_update_p (gimple_phi_result (phi)))
+           break;
+         else if (tree rhs = degenerate_phi_result (phi))
            res = rhs;
          else
            break;
Comment 3 Richard Biener 2018-03-08 11:20:57 UTC
So this is really a latent issue and not dependent on -floop-nest-optimize.  It
materializes during unrolling where we perform SCEV analysis on not up-to-date SSA form when analyzing.
Comment 4 Richard Biener 2018-03-08 14:42:11 UTC
Author: rguenth
Date: Thu Mar  8 14:41:39 2018
New Revision: 258365

URL: https://gcc.gnu.org/viewcvs?rev=258365&root=gcc&view=rev
Log:
2018-03-08  Richard Biener  <rguenther@suse.de>

	PR middle-end/84552
	* tree-scalar-evolution.c: Include tree-into-ssa.h.
	(follow_copies_to_constant): Do not follow SSA names registered
	for update.

	* gcc.dg/graphite/pr84552.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/graphite/pr84552.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-scalar-evolution.c
Comment 5 Jakub Jelinek 2018-10-26 10:14:15 UTC
GCC 6 branch is being closed
Comment 6 Richard Biener 2019-03-26 11:18:58 UTC
Author: rguenth
Date: Tue Mar 26 11:18:26 2019
New Revision: 269939

URL: https://gcc.gnu.org/viewcvs?rev=269939&root=gcc&view=rev
Log:
2019-03-26  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2019-01-08  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/86554
	* tree-ssa-sccvn.c (visit_nary_op): When value-numbering to
	expressions with different overflow behavior make sure there's an
	available expression on the path.

	* gcc.dg/torture/pr86554-1.c: New testcase.
	* gcc.dg/torture/pr86554-2.c: Likewise.

	2018-11-20  Richard Biener  <rguenther@suse.de>
 
	PR tree-optimization/88105
	* tree-ssa-dom.c (pass_dominator::execute): Do not walk
	backedges.

	* gcc.dg/gomp/pr88105.c: New testcase.

	2018-03-08  Richard Biener  <rguenther@suse.de>

	PR middle-end/84552
	* tree-scalar-evolution.c: Include tree-into-ssa.h.
	(follow_copies_to_constant): Do not follow SSA names registered
	for update.

	* gcc.dg/graphite/pr84552.c: New testcase.

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/gomp/pr88105.c
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/graphite/pr84552.c
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/torture/pr86554-1.c
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/torture/pr86554-2.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/tree-scalar-evolution.c
    branches/gcc-7-branch/gcc/tree-ssa-dom.c
    branches/gcc-7-branch/gcc/tree-ssa-sccvn.c
Comment 7 Richard Biener 2019-03-26 11:20:14 UTC
Fixed.