https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120443
Bug ID: 120443 Summary: [16 regression] wrong code at -O3 Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: chopra.kavya04 at gmail dot com Target Milestone: --- appears to be a recent regression from the trunk. godbolt link: https://godbolt.org/z/4fGfr8Eah ``` kchopra@ast-epyc0:~$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/local/home/kchopra/compilers/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-bootstrap --enable-checking=yes --prefix=/local/home/kchopra/compilers --enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib : (reconfigured) ../configure --disable-bootstrap --enable-checking=yes --prefix=/local/home/kchopra/compilers --enable-sanitizers --enable-languages=c,c++ --disable-werror --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 16.0.0 20250522 (experimental) (GCC) kchopra@ast-epyc0:~$ gcc -O0 bug.c; ./a.out -1 kchopra@ast-epyc0:~$ gcc -O3 bug.c; ./a.out -227068033 kchopra@ast-epyc0:~$ cat bug.c int printf(const char *, ...); int a, b, c, ae, af; int d(int e, int f, int ag) { g: if (f <= 0) goto j; c = -2 - e - 227068031; if (a + 7) goto h; goto j; h: ae = -e - 1920415615 * c + 2147483648; i: if (b - ag - f + 1290222195 >= 0) goto j; if (ae) return ae; goto g; ai: af = 558007421 * ag; if (af >= 0) goto i; e = 0; goto h; j: ag = ag - 184330119 * ae; goto ai; } int main() { int ak = d(-227068032, 1290222211, -184330117); printf("%d\n", ak); return 0; } ```