From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3283 invoked by alias); 10 Oct 2013 05:10:26 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 3248 invoked by uid 48); 10 Oct 2013 05:10:21 -0000 From: "su at cs dot ucdavis.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/58677] New: wrong code at -O1 on x86_64-linux-gnu Date: Thu, 10 Oct 2013 05:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: su at cs dot ucdavis.edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg00524.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58677 Bug ID: 58677 Summary: wrong code at -O1 on x86_64-linux-gnu Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The current gcc trunk miscompiles the attached testcase on x86_64-linux at (only) -O1 in 64-bit mode. This is a regression from 4.8.x. This one was quite tough to reduce. The attached testcase is the best I was able to get so far. $ 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 --enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror --enable-checking=release --with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk Thread model: posix gcc version 4.9.0 20131009 (experimental) [trunk revision 203302] (GCC) $ $ gcc-trunk -O0 small.c; a.out 0 0 1 $ gcc-4.8 -O1 small.c; a.out 0 0 1 $ gcc-trunk -m32 -O1 small.c; a.out 0 0 1 $ clang-trunk -O1 small.c; a.out 0 0 1 $ gcc-trunk -O1 small.c; a.out 0 0 0 $ ------------------------------------- int printf (const char *, ...); #pragma pack(1) struct S { unsigned int f0:7; int f1:19; unsigned int f2:22; int f3:25; } k[6][8]; int a, b, c, e, h, l, m, n, o, *p = &h, **q = &p, r, s; unsigned int d[256]; static void fn1 () { for (a = 0; a < 256; a++) d[a] = a; } static void fn2 (unsigned int p1, char *p2, int p3) { e = d[e ^ p1]; printf ("%s%X\n", p2, e); } static int * fn3 (int p1, int p2) { for (s = 10; s > 2; s = -6) for (r = 0; r < 6; r++) for (n = 0; n < 8; n++) { struct S t = { 1, -195, 321, 4857 }; k[r][n] = t; } return *q; } static int fn4 () { *q = fn3 (l, b); return c; } int main (int argc, char *argv[]) { int v = 0; if (argc == 2) v = 1; fn1 (); fn4 (); fn2 (m, "", v); fn2 (o, "", v); fn2 (k[0][0].f0, "", v); return 0; }