https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121557
Bug ID: 121557
Summary: wrong code at -O3 on x86_64-linux-gnu (generated code
hangs)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zhendong.su at inf dot ethz.ch
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/7Y9s1rcWd
Note:
- works: 10.* and earlier
- fails: 11.* and later
- -fno-tree-slsr makes it disappear
[528] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.0 20250814 (experimental) (GCC)
[529] %
[529] % gcctk -O2 small.c; ./a.out
[530] %
[530] % gcctk -O3 small.c
[531] % timeout -s 9 5 ./a.out
Killed
[532] % cat small.c
int c, d, e, f, g, h, j;
int a[] = {
0, 8, 4, 7, 5, 5,
5, 4, 2044508324, 0, 4, 5,
1, 7, 4049, 8, 6, 4089016648,
4, 50548861, 3, 107580753, 9, 0,
2, 2, 6, 7, 5, 5,
7, 7073096, 6, 2, 2, 1006888145,
607687, 101629, 3, 901097722, 9000684, 6,
8065728, 1, 1, 705015759, 5, 0,
6, 4, 104598, 3, 1, 5,
3099436303, 4, 4, 30930, 70347812, 7,
5, 5, 3060149565, 2, 4, 2,
4023717930, 907459465, 5, 3, 904427059, 2013776290,
6, 4, 0, 3, 3, 9,
7, 802195444, 6, 8001368, 4066508878, 70925,
3092731, 5, 3, 706088902, 4, 2,
2, 1, 7, 3, 5, 303535960,
6, 7007092, 9037538, 70817, 1, 3,
4079995, 6, 6, 909243462, 6, 7,
7, 1, 708648649, 8, 6, 6048,
4, 909, 5, 10523913, 5, 4,
702138776, 0, 2, 504918807, 3, 3082640443,
9, 4, 6, 70685, 1, 70997,
3, 0, 4, 0, 2053790376, 5,
3, 3, 2097651377, 4027552580, 90386, 2,
2050814, 5, 5, 5, 507879, 6,
0, 6, 2, 708143, 5, 3,
7, 604390888, 8, 2, 6, 5,
60999, 1068828381, 9, 0, 8, 906185462,
1090812512, 3, 9, 5, 1, 4,
60834842, 8085408, 6, 109, 8078467, 3,
400815, 2, 608, 4, 6, 1,
5, 3, 1, 607071920, 0, 2,
40735498, 5, 1, 3087877, 908371, 4,
803740692, 2075208622, 2, 3, 90285, 2094854071,
1, 2029012, 0, 2, 0, 1,
5, 1, 7, 4, 200368, 4,
6, 405801727, 5, 5, 1, 5067896,
608007406, 308918612, 8, 808555105, 3, 1,
5, 8, 703836, 1088359270, 0, 9,
9, 202900863, 7, 108, 0, 2,
0, 2074933, 9, 3009837614, 6, 6,
4, 3020668471, 5};
int k(int l, char m) { return a[(l ^ m) & 255]; }
int n(int l, int m[]) {
int i = 0;
for (; i < l; ++i) {
c = a[(e ^ m[i]) & 255];
d = a[c & 15];
e = d = k(d, m[i] >> 24);
}
return d;
}
int o(int l) {
int b = 2;
h = l + 2000;
if (j)
b = 0;
f = h - b - 2;
h = -1000 - b + 1000 * f;
g = -1000 - b - 999 * f;
int p[] = {f, b, g, l, d, h};
return n(6, p);
}
int main() {
while (o(-2147456) < 1)
;
}