https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129117

            Bug ID: 129117
           Summary: [14/15/16/17 Regression] compile-time hog at -O1 and
                    -O2 in ranger on a chain of _Bool ORs, exponential in
                    its length
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: compile-time-hog
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shimizu2486 at gmail dot com
  Target Milestone: ---

Live reproducer: https://godbolt.org/z/3jTzjbnbf

$ cat t1.c
#define S x = A | ((q >= x) | !x);
int f(int a, unsigned q) {
  _Bool A = !a, x = q;
  S S S S S S S S S S S
  return x ? a : 0;
}

$ time gcc -O1 -c t1.c
real    0m3.9s
$ time gcc -O2 -c t1.c
real    0m40.4s
$ time gcc -O0 -c t1.c
real    0m0.0s

                                  -O1       -O2
  x86_64 trunk (4882367b8618)     3.9 s    40.4 s
  x86_64 16.2.0                   3.7 s    39.8 s
  x86_64 15.3.0                   3.3 s    22.7 s
  x86_64 14.4.0                   3.8 s    26.0 s
  x86_64 13.5.0                   3.6 s    25.1 s
  x86_64 12.5.0                   0.0 s     5.0 s
  x86_64 11.5.0                   0.0 s     0.0 s

Each S more makes it about 4.4 times slower in my env.
With trunk at -O1, 10 of them take 0.9 s, 11 3.9 s, 12 17.0 s and 13 76.1 s.

-ftime-report shows dominator optimization 100% at -O1.
It blames tree Early VRP 46%, tree VRP 45% and dominator optimization 9% at
-O2. 
-O1 -fno-tree-dominator-opts takes 0.0 s, and so does -O2 -fno-tree-vrp
-fno-tree-dominator-opts.
--param=ranger-logical-depth=3, 9 or 12 is as slow as the default 6. Byt with
1, 2, 4, 5, 7 or 8 it takes 0.0 s.

Reply via email to