https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122913
Bug ID: 122913
Summary: [16 Regression?] pr12392.cpp -Ofast compile time went
up 66% when switching to -std=c++20
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: compile-time-hog
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
With a --enable-checking=yes build we get:
```
[apinski@xeond2 gcc]$ time ~/upstream-gcc/bin/gcc -std=c++20 t.cc -Ofast
-fno-checking -S
real 0m59.201s
user 0m58.610s
sys 0m0.405s
[apinski@xeond2 gcc]$ time ~/upstream-gcc/bin/gcc -std=c++17 t.cc -Ofast
-fno-checking -S
real 0m35.656s
user 0m35.249s
sys 0m0.295s
```
The problem does not look like the C++ parsing time changes:
std=c++20:
```
phase setup : 0.01 ( 0%) 1766k ( 0%)
phase parsing : 1.54 ( 3%) 151M ( 21%)
phase lang. deferred : 0.23 ( 0%) 17M ( 2%)
```
vs -std=c++17:
```
phase setup : 0.01 ( 0%) 1764k ( 0%)
phase parsing : 1.25 ( 3%) 116M ( 24%)
phase lang. deferred : 0.17 ( 0%) 16M ( 3%)
```
The biggest difference is:
std=c++20:
```
PRE : 12.62 ( 21%) 2437k ( 0%)
```
vs -std=c++17:
```
PRE : 2.84 ( 8%) 1510k ( 0%)
```
So this looks like a difference in the IR going through the compiler which is
causing the difference. I don't know if it is due to libstdc++ being different
between 17 and 20 or the front-end producing different IR.
https://lnt.opensuse.org/db_default/v4/CPP/graph?plot.0=174.585.8
I also noticed leela_r at `-O2 -flto` lost the small speedup which was gained
from my cleanupcfg patches too from moving to C++20 too:
https://lnt.opensuse.org/db_default/v4/SPEC/graph?plot.0=298.397.0
I don't know if this is related though.