public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/51987] New: [4.7 Regression] Predictive commoning wrong-code with non-volatile asm
@ 2012-01-24 22:41 jakub at gcc dot gnu.org
2012-01-24 22:53 ` [Bug tree-optimization/51987] " jakub at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-24 22:41 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/51987] [4.7 Regression] Predictive commoning wrong-code with non-volatile asm
2012-01-24 22:41 [Bug tree-optimization/51987] New: [4.7 Regression] Predictive commoning wrong-code with non-volatile asm jakub at gcc dot gnu.org
@ 2012-01-24 22:53 ` jakub at gcc dot gnu.org
2012-01-24 23:17 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-24 22:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51987
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2012-01-24
Target Milestone|--- |4.7.0
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/51987] [4.7 Regression] Predictive commoning wrong-code with non-volatile asm
2012-01-24 22:41 [Bug tree-optimization/51987] New: [4.7 Regression] Predictive commoning wrong-code with non-volatile asm jakub at gcc dot gnu.org
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
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-24 23:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51987
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-24 22:40:11 UTC ---
Created attachment 26449
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26449
gcc47-pr51987.patch
Untested fix.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/51987] [4.7 Regression] Predictive commoning wrong-code with non-volatile asm
2012-01-24 22:41 [Bug tree-optimization/51987] New: [4.7 Regression] Predictive commoning wrong-code with non-volatile asm jakub at gcc dot gnu.org
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
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-25 16:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51987
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-25 15:38:57 UTC ---
Author: jakub
Date: Wed Jan 25 15:38:51 2012
New Revision: 183524
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183524
Log:
PR tree-optimization/51987
* tree-data-ref.c (get_references_in_stmt): Handle references in
non-volatile GIMPLE_ASM.
* gcc.target/i386/pr51987.c: New test.
Added:
trunk/gcc/testsuite/gcc.target/i386/pr51987.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-data-ref.c
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/51987] [4.7 Regression] Predictive commoning wrong-code with non-volatile asm
2012-01-24 22:41 [Bug tree-optimization/51987] New: [4.7 Regression] Predictive commoning wrong-code with non-volatile asm jakub at gcc dot gnu.org
` (2 preceding siblings ...)
2012-01-25 16:13 ` jakub at gcc dot gnu.org
@ 2012-01-25 16:40 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-25 16:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51987
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-25 16:22:35 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-25 16:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 22:41 [Bug tree-optimization/51987] New: [4.7 Regression] Predictive commoning wrong-code with non-volatile asm jakub at gcc dot gnu.org
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
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).