https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121675
Bug ID: 121675 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/MMjE5oeWG Note: - works: 8.5 and earlier - fails: 9.1 and later - -fno-tree-slsr and -fno-ivopts do not make 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 20250825 (experimental) (GCC) [520] % [520] % gcctk -O3 small.c [521] % ./a.out Aborted [522] % gcctk -O3 -fno-tree-slsr -fno-ivopts small.c [523] % ./a.out Aborted [524] % cat small.c int a, c, d, e; int b(volatile int f, int g) { f = -2; if (!f) a = 1; c = 11 / f - g + 2; g = c + 2; if (!(1 / c + (g - 1))) a = 1; return a + f; } int main() { do { e = (b(1, -1) - 30885397) % 2 - 3; d = b(1, -1) - 1430885400; } while (a + 1 == 0); if (d + e != -1430885406) __builtin_abort(); return 0; }