https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129128
Bug ID: 129128
Summary: [17 Regression] Compile-time hog in RTL expansion
(alias stmt walking) at -O3 on many small
array-initialization loops
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: lyfanyang at smail dot nju.edu.cn
Target Milestone: ---
Created attachment 66322
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66322&action=edit
reduced testcase
The attached `hog.c` (208 lines) contains 76 small nested loops that fill
global arrays. On trunk (20261108, configured with `--enable-checking=yes`) it
compiles in a fraction of a second at -O1/-O2 but takes about 14 s at -O3:
```
$ gcc -O1 -c hog.c # 0.3 s
$ gcc -O2 -c hog.c # 0.4 s
$ gcc -O3 -c hog.c # 14 s
```
This is a regression in the 17 development cycle: 9.4.0 and 16.2.0 compile the
same file at -O3 in well under 0.1 s.
`-ftime-report` at -O3 shows the time is in RTL expansion, not in the
vectorizer:
```
callgraph functions expansion : 13.75 ( 99%) 65M ( 95%)
alias stmt walking : 7.05 ( 51%) 35M ( 52%)
load CSE after reload : 2.00 ( 14%)
tree DSE : 0.84 ( 6%)
tree loop distribution : 0.44 ( 3%)
tree vectorization : 0.42 ( 3%)
CSE : 0.43 ( 3%)
scheduling 2 : 0.33 ( 2%)
```
`-fno-tree-vectorize` halves the time (14 s -> ~7 s), so the loop vectorizer
contributes by transforming the loops, but the time itself is spent in RTL
expansion's alias stmt walking. The residual ~7 s at `-O3 -fno-tree-vectorize`
shows a second O3-only factor is also involved.
The reduction stops at ~76 loops: with fewer loops, -O3 no longer triggers the
hog, so the cost scales with the number of loops. The program has no undefined
behavior (it is clean under `-fsanitize=address,undefined`); it is a reduced
slice of a YARPGen-generated program (many small loops that fill arrays).
## Attachments
- `hog.c`: reduced testcase (208 lines, 76 loops)