https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121556
Bug ID: 121556 Summary: wrong code at -O3 on x86_64-linux-gnu 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/eeasrbce7 Note: - works: 9.* and earlier - fails: 10.* and later - -fno-tree-slsr makes it disappear [519] % 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) [520] % [520] % gcctk -O3 small.c [521] % ./a.out Aborted [522] % cat small.c int printf (const char *, ...); int a, b, c, d, f, g; int e[] = { 0, 5, 5, -565230030, 2044508324, 0, 4, 1, 7, -655623580, 6, 4089016648, 453116029, 3, 107580753, 9, 0, 2, 2, 6, 7, 5, 5, 7, 7073096, 6, 2, 2, 1006888145, 607687, 101629, 3, 901097722, 9000684, 6, 8065728, 705015759, 5, 0, 6, 69554304, 1, 5, 3099436303, 4, 4, 30930, 70347812, 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, 314042704, 2, 2, 1, 7, 3, 5, 303535960, 6, 7007092, 9037538, 70817, 1, 6, 909243462, 6, 7, 7, 1, 708648649, 42533948, 876714000, 4, 909, 5, 10523913, 5, 4, 702138776, 0, 2, -1447152767, 3082640443, 3233442989, 4, 7068, 10842, 5, 1, 70997, 3, 0, 596804, 0, 2053790376, 5, 3, 3, 2097651377, 4027552580, -1083300248, 2050814, 5, 5, 5, 507879, 6, 0, 6, 2, 708143, 5, 3, 7, 604390888, 8, 5, 60999, 1068828381, 9, 0, 8, 906185462, 1090812512, 3, 9, 5, 4, 60834842, 8085408, 6, 109, 8078467, 3, 1426400815, 2, 4, 6, 1, 5, 3, 1541320221, 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, 3736837829}; int h(int j, char k) { return (j >> 8 & 16777215) ^ e[(j ^ k) & 255]; } int l(int j) { a = h (a, j >> 8); a = d = a >> 8 ^ e[0]; a = h (a, j >> 24); return a; } int m() { f = l(0); return f; } void n(int j, int k) { int o = 1, i = 0; do { k = - --j; b = k - 3; o = -o; } while (m()); k = -1000 - o + 1000 * b; g = -1000 - o - 999 * b; int p[] = {b, o, g, j, c, k}; for (; i < 6; ++i) l (p[i]); } int main() { do { n (-2147460, 3); } while (!a); if (a != 31) __builtin_abort(); return 0; }