https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128996
Bug ID: 128996
Summary: compile-time hog at -O3 in backwards jump threading on
an unrolled loop of __builtin_add_overflow into a
_BitInt(24)
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/j1Gne4qY1
$ cat t1.c
int g, x;
_BitInt(3) n;
int main(void) {
for (; n; n++) {
short l = g;
for (int i = 0; i < 14 && l > (g > 0); i++) {
_BitInt(24) r;
l = (__builtin_add_overflow(l, 1, &r) ?: r) - l;
}
x = l;
}
}
$ time gcc -O3 -c t1.c
real 0m5.3s
$ time gcc -O2 -c t1.c
real 0m0.0s
x86_64 trunk (2f817b3ea9e9) 5.3 s
x86_64 16.2.0, 15.3.0, 14.4.0 0.1 s
in my local env, -ftime-report at -O3 shows backwards jump threading 66%,
dominator optimization 18% and tree VRP 16%.
-O3 -fno-tree-vrp takes 0.1 s and -O3 -fno-thread-jumps 1.6 s.
-O2 -funroll-loops takes 1.4 s.
With gcc 16.2.0, this compile-time surge doesn't happen so I suppose this is 17
regression.