https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121378
Bug ID: 121378 Summary: wrong code at -O2 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/xnjGa3njq Note: * This is a recent regression as it doesn't reproduce with 15.1 and earlier. * -fno-ivopts makes it disappear (but not -fno-tree-slsr) [513] % 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 20250803 (experimental) (GCC) [514] % [514] % gcctk -O0 small.c [515] % ./a.out [516] % [516] % gcctk -O2 small.c [517] % ./a.out Aborted [518] % cat small.c int printf(const char *, ...); int a, b, c, d, f, g, h, i, j, k, l; int m(int n, int o[]) { for (int e = 0; e < n; ++e) { b = a ^ o[e]; a = b; } return b; } static int p(int n, int o, int p3) { do { j = -p3 - 9; if (!(g + 9)) break; g = -j; o = o - n; } while (g - 99 * o + c > 0); return m(12, (int[]){h, 0, l, i, c, d, f, g, o, j, p3, k}); } void q() { p(5, 1, -2147483646); } int main() { p(-2147483647, -2147483647, -2147483647); if (b != 2147483645) __builtin_abort(); return 0; }