public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/51987] New: [4.7 Regression] Predictive commoning wrong-code with non-volatile asm Date: Tue, 24 Jan 2012 22:41:00 -0000 [thread overview] Message-ID: <bug-51987-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51987 Bug #: 51987 Summary: [4.7 Regression] Predictive commoning wrong-code with non-volatile asm Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: jakub@gcc.gnu.org ReportedBy: jakub@gcc.gnu.org On s390 (31-bit) gcc 4.7 miscompiles _itoa.o and _itoa.os in glibc (which leads to e.g. cc1 itself when using that glibc to crash on startup). Here is a reduced testcase (for x86_64): extern void abort (void); union U { unsigned long l; struct { unsigned int l, h; } i; }; __attribute__((noinline, noclone)) void foo (char *x, char *y) { int i; for (i = 0; i < 64; i++) { union U u; asm ("movl %1, %k0; salq $32, %0" : "=r" (u.l) : "r" (i)); x[i] = u.i.h; union U v; asm ("movl %1, %k0; salq $32, %0" : "=r" (v.l) : "r" (i)); y[i] = v.i.h; } } int main () { char a[64], b[64]; int i; foo (a, b); for (i = 0; i < 64; i++) if (a[i] != i || b[i] != i) abort (); return 0; } This is miscompiled at -O3, predictive commoning ignores the references in the inline-asm and happily moves loads of u.i.h and v.i.h before the loop, even when it is initialized only by the inline asm inside of the loop. The problem is that tree-data-ref.c (get_references_in_stmt) gives up on GIMPLE_ASM only if it is volatile, and for non-volatile GIMPLE_ASM it just (incorrectly) assumes it doesn't have any references.
next reply other threads:[~2012-01-24 22:31 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-01-24 22:41 jakub at gcc dot gnu.org [this message] 2012-01-24 22:53 ` [Bug tree-optimization/51987] " jakub at gcc dot gnu.org 2012-01-24 23:17 ` jakub at gcc dot gnu.org 2012-01-25 16:13 ` jakub at gcc dot gnu.org 2012-01-25 16:40 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-51987-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).