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

            Bug ID: 108138
           Summary: g++ 9+ takes 7-10x longer compiling constexpr
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: peter at meraki dot com
  Target Milestone: ---

Created attachment 54107
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54107&action=edit
testcase

The attached testcase takes ~24s to compile on gcc 8.4.0 but takes ~172s with
gcc 11.1.0:

g++-8 -std=gnu++11 -Wall -Werror -ftime-report -c constexpr-testcase2.cc

Time variable                                   usr           sys          wall
              GGC
 phase setup                        :   0.01 (  0%)   0.00 (  0%)   0.02 (  0%)
   1495 kB ( 32%)
 phase parsing                      :  19.02 (100%)   5.05 (100%)  24.07 (100%)
   3197 kB ( 68%)
 |name lookup                       :   0.01 (  0%)   0.01 (  0%)   0.02 (  0%)
    102 kB (  2%)
 |overload resolution               :   6.60 ( 35%)   1.61 ( 32%)   7.87 ( 33%)
    474 kB ( 10%)
 preprocessing                      :   0.01 (  0%)   0.01 (  0%)   0.00 (  0%)
    264 kB (  6%)
 parser (global)                    :   0.00 (  0%)   0.00 (  0%)   0.02 (  0%)
    576 kB ( 12%)
 parser inl. func. body             :   2.34 ( 12%)   0.72 ( 14%)   2.83 ( 12%)
   2325 kB ( 49%)
 constant expression evaluation     :  16.67 ( 88%)   4.32 ( 86%)  21.22 ( 88%)
     31 kB (  1%)
 TOTAL                              :  19.03          5.05         24.09       
   4709 kB

g++-11 -Wall -Werror -ftime-report -c constexpr-testcase2.cc

Time variable                                   usr           sys          wall
          GGC
 phase setup                        :   0.00 (  0%)   0.00 (  0%)   0.01 (  0%)
 1553k (  4%)
 phase parsing                      : 165.22 (100%)   7.55 (100%) 172.78 (100%)
   36M ( 96%)
 |name lookup                       :   0.02 (  0%)   0.00 (  0%)   0.00 (  0%)
  102k (  0%)
 |overload resolution               :  82.10 ( 50%)   4.00 ( 53%)  85.99 ( 50%)
   17M ( 46%)
 preprocessing                      :   0.01 (  0%)   0.02 (  0%)   0.01 (  0%)
  224k (  1%)
 parser (global)                    :   0.00 (  0%)   0.00 (  0%)   0.01 (  0%)
  579k (  1%)
 parser inl. func. body             :   2.92 (  2%)   0.12 (  2%)   2.82 (  2%)
 5336k ( 14%)
 constant expression evaluation     : 162.29 ( 98%)   7.41 ( 98%) 169.94 ( 98%)
   30M ( 80%)
 TOTAL                              : 165.22          7.55        172.79       
   38M


The dramatic slowdown appears to have been introduced in gcc 9
The best wall time (of versions tested) was gcc 7.5 at ~15s
The worst wall time was gcc 10.3 at ~180s

The wordlist was trivially constructed from:
wget https://www.mit.edu/~ecprice/wordlist.10000
head -1000 wordlist.10000 | sed 's/\(.*\)/CHECK(\1)/' > wordlist.1000.hh

Reply via email to