http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60116
Bug ID: 60116 Summary: wrong code at -Os on x86_64-linux-gnu in 32-bit mode Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The current gcc trunk and 4.8.x mis-compile the following code on x86_64-linux at -Os in 32-bit mode (but not 64-bit). This is a regression from 4.7.x. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 4.9.0 20140207 (experimental) [trunk revision 207610] (GCC) $ $ gcc-trunk -m32 -O1 small.c; a.out 1 $ gcc-trunk -m64 -Os small.c; a.out 1 $ gcc-4.7.3 -m32 -Os small.c; a.out 1 $ $ gcc-trunk -m32 -Os small.c; a.out 0 $ gcc-4.8.2 -m32 -Os small.c; a.out 0 $ ------------------------------------- int printf (const char *, ...); int a, b, c, d = 1, e, f = 1, h, i, k; char g, j; int fn1 () { int l; e = 0; c = 0; for (;;) { k = a && b; j = k * 54; g = j * 147; l = ~g + (long long) e && 1; if (d) c = l; else h = i = l * 9UL; if (f) return 0; } } int main () { fn1 (); printf ("%d\n", c); return 0; }