https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121558
Bug ID: 121558
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/jqMT416f3
Note:
- fails: 12.* and later
- works: 11.* and earlier
- -fno-tree-slsr makes it disappear
- might be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121557
[537] % 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)
[538] %
[538] % gcctk -O2 small.c; ./a.out
[539] % gcctk -O3 small.c
[540] % timeout -s 9 5 ./a.out
Killed
[541] % cat small.c
int a, b, d, e, f;
int c[] = {
0, 4, 5, 5, 5, 4, 4049,
8, 6, -205950648, 4, 50548861, 3, 107580753,
9, 0, 2, 2, 6, 5, 5,
6, 2, 2, 1006888145, 607687, 101629, 9000684,
6, 4, 104598, 3, 1, 2097651377, -1461312586};
int m(int n) {
int j, l, g, h = 0;
unsigned i = 4294967295;
b = n + 999;
d = b - 1 - a;
if (b < d)
a = -a;
b = -1000 - a + 1000 * d;
e = -1000 - a - 999 * d;
int k[] = {d, a, e, n, f, b};
for (; h < 6; ++h) {
g = i ^ c[(i ^ k[h]) & 55];
l = g >> 8 ^ (g & 55);
i = l;
}
j = i = i ^ 4294967295;
return j;
}
int main() {
while (m(-2147460) > 0)
;
}