https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87177
Bug ID: 87177 Summary: wrong code at -O2 and -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: su at cs dot ucdavis.edu Target Milestone: --- It is a recent regression. $ gcctk -v Using built-in specs. COLLECT_GCC=gcctk COLLECT_LTO_WRAPPER=/home/su/software/tmp/gcc/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/home/su/software/tmp/gcc/gcc-trunk --disable-bootstrap Thread model: posix gcc version 9.0.0 20180831 (experimental) [trunk revision 264021] (GCC) $ $ gcctk -Os small.c; ./a.out $ gcc-8.1.0 -O2 small.c; ./a.out $ $ gcctk -O2 small.c $ timeout -s 9 5 ./a.out Killed $ ----------------------------------------- int printf (const char *, ...); int a, b, c, e, f, g, h, i, j, k, l; unsigned d; static void p () { while (1) { int n = h; h = 8; if (!e) break; h = n; while (1) ; } for (; c != 4; c++) { int o = g = 1; for (; g; g--) { while (d < b) e--; a = g; int q = o; if (q) L1: j = f; if (l) { printf ("%d", g); goto L1; } o = l; k = q; } } } void s () { int m = 0; L2: if (i && g) goto L2; for (; m < 2; m++) p (); } int main () { s (); return 0; }