https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120583
Bug ID: 120583 Summary: wrong code at -O{s,2} 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/1rfPr96s4 - works: 9.* and earlier - fails: 10.* and later It seems to be fixed by -fno-ivopts (but not -fno-tree-slsr). [511] % 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 20250607 (experimental) (GCC) [512] % [512] % gcctk -O2 small.c [513] % ./a.out Aborted [514] % gcctk -O2 -fno-ivopts small.c [515] % ./a.out [516] % [516] % cat small.c int a, b, c; static int d(int e) { do { c = a = -998 * b - 5000000; b = e + b - 2148000; } while (c <= 0 && 10 * b - a <= 0); return c; } int main() { if (a) d(1); if (d(0) != 2138704000) __builtin_abort(); return 0; }