public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/49758] New: -O2 incorrectly swaps overlapping memory accesses
@ 2011-07-16 6:45 arthur.j.odwyer at gmail dot com
2011-07-16 6:46 ` [Bug target/49758] " arthur.j.odwyer at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2011-07-16 6:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49758
Summary: -O2 incorrectly swaps overlapping memory accesses
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: arthur.j.odwyer@gmail.com
Created attachment 24776
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24776
Output of "ajo-gcc -w -O1 test.c -v"
This failure reproduces for me with svn revision 176128 (2011-07-10). I'm on
Ubuntu 10.10, x86-64. It looks like bug 36043 may be related.
cat >test.c <<EOF
static volatile struct S0 {
short f3[9];
unsigned f8 : 15;
} s = {1};
static unsigned short sh = 0x1234;
struct S0 a, b;
int vi = 0;
void func_4() {
s.f8 |= 1;
sh = 15;
if (vi) a = b;
}
int main() {
func_4();
printf("%hx\n", sh);
return 0;
}
EOF
gcc -w -O1 test.c ; ./a.out
gcc -w -O2 test.c ; ./a.out
With -O1, we correctly print "f". With -O2, we incorrectly print "1234".
With -O1 we have the following assembly code:
[...]
movq s+16(%rip), %rax
andq $-2147418113, %rax
orq %rdx, %rax
movq %rax, s+16(%rip)
movw $15, sh(%rip)
[...]
With -O2 the scheduler has incorrectly swapped the movw into the middle of the
volatile struct access:
[...]
movq s+16(%rip), %rdx
movq s+16(%rip), %rax
movw $15, sh(%rip)
andl $2147352576, %edx
andq $-2147418113, %rax
orq $65536, %rdx
orq %rdx, %rax
movq %rax, s+16(%rip)
[...]
This test case is reduced from the output of Csmith 2.1.0 (git hash 01aa8b04,
https://github.com/Quuxplusone/csmith/), using the following command line:
csmith --paranoid --no-longlong --no-pointers --no-arrays --no-jumps
--no-consts --volatiles --checksum --no-divs --no-muls --bitfields
--packed-struct -s 320690328
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/49758] -O2 incorrectly swaps overlapping memory accesses
2011-07-16 6:45 [Bug target/49758] New: -O2 incorrectly swaps overlapping memory accesses arthur.j.odwyer at gmail dot com
@ 2011-07-16 6:46 ` arthur.j.odwyer at gmail dot com
2011-07-16 7:29 ` jakub at gcc dot gnu.org
2012-02-01 13:00 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2011-07-16 6:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49758
--- Comment #1 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> 2011-07-16 06:46:24 UTC ---
Created attachment 24777
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24777
Output of "ajo-gcc -w -O2 test.c -v"
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/49758] -O2 incorrectly swaps overlapping memory accesses
2011-07-16 6:45 [Bug target/49758] New: -O2 incorrectly swaps overlapping memory accesses arthur.j.odwyer at gmail dot com
2011-07-16 6:46 ` [Bug target/49758] " arthur.j.odwyer at gmail dot com
@ 2011-07-16 7:29 ` jakub at gcc dot gnu.org
2012-02-01 13:00 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-16 7:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49758
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-16 07:28:40 UTC ---
More probably dup of PR48124.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/49758] -O2 incorrectly swaps overlapping memory accesses
2011-07-16 6:45 [Bug target/49758] New: -O2 incorrectly swaps overlapping memory accesses arthur.j.odwyer at gmail dot com
2011-07-16 6:46 ` [Bug target/49758] " arthur.j.odwyer at gmail dot com
2011-07-16 7:29 ` jakub at gcc dot gnu.org
@ 2012-02-01 13:00 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-02-01 13:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49758
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-01 12:57:12 UTC ---
Fixed by my proposed fix for PR48124.
*** This bug has been marked as a duplicate of bug 48124 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-01 13:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-16 6:45 [Bug target/49758] New: -O2 incorrectly swaps overlapping memory accesses arthur.j.odwyer at gmail dot com
2011-07-16 6:46 ` [Bug target/49758] " arthur.j.odwyer at gmail dot com
2011-07-16 7:29 ` jakub at gcc dot gnu.org
2012-02-01 13:00 ` rguenth 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).