https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77856
Bug ID: 77856 Summary: wrong code at -O2 on x86_64-linux-gnu in 32-bit mode Product: gcc Version: 7.0 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 regression from 6.2.x. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 7.0.0 20161004 (experimental) [trunk revision 240755] (GCC) $ $ gcc-6.2 -m32 -O2 small.c; ./a.out 1 $ gcc-trunk -m32 -Os small.c; ./a.out 1 $ $ gcc-trunk -m32 -O2 small.c; ./a.out 64 $ $ ---------------------------------------------------------- int printf (const char *, ...); unsigned a, e; struct S0 { int f1; int f8; } c = {4, 6}; int b, f, g, h, i, j, l, p; short d, o = -7; char k, n = 5; unsigned fn1 (int p1, int p2) { return p2 >= 2 || p1 >> p2 ? p1 : p1 << p2; } static short fn2 (struct S0 p1) { int *q = 0; int r = 7; if (!a) { c.f1 = 1; for (; c.f1; c.f1--) if (fn1 (10 != 0, p1.f8)) { short s = 9 << ~o % (d ^ n); int t = s >> h % ~d; p = r; r = s | p * (d && 9) | t; int u = i & c.f1; unsigned v = ~(~(u & h) | (~(8 >> c.f1) & i)); int w = v; if (u < 9) w = c.f1; if (i > h && u) { printf ("%d\n", c.f1); continue; } c.f1 = w; if (!p) continue; return 0; } for (;;) *q = 0; } return 0; } static void fn3 () { fn2 (c); l = c.f1 < b; if (l) { L1: e = l | j / e % ~f; j = f - 4 % k < c.f1 / e / b - j - 1; if (l) { printf ("%d\n", b); goto L1; } int m[245]; g = m[2]; } } int main () { fn3 (); printf ("%d\n", c.f1); return 0; }