public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "borysp at invisiblethingslab dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/99258] New: volatile struct access optimized away
Date: Wed, 24 Feb 2021 18:17:29 +0000 [thread overview]
Message-ID: <bug-99258-4@http.gcc.gnu.org/bugzilla/> (raw)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99258
Bug ID: 99258
Summary: volatile struct access optimized away
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: borysp at invisiblethingslab dot com
Target Milestone: ---
Access to a volatile struct is optimized away, if the size of the struct is
>16B (at least on x64 cpu with sse). Small repro:
[borys@mowmiwuju test]$ cat a.c
struct A {
long a;
long b;
};
struct B {
long a;
long b;
long c;
};
void f(volatile struct A* x) {
*x;
}
void g(volatile struct B* x) {
*x;
}
[borys@mowmiwuju test]$ gcc --version
gcc (GCC) 10.2.0
[borys@mowmiwuju test]$ gcc -Wall -Wextra -std=c11 -O2 -c a.c
[borys@mowmiwuju test]$ objdump -d -Mintel a.o
a.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <f>:
0: f3 0f 6f 07 movdqu xmm0,XMMWORD PTR [rdi]
4: c3 ret
5: 66 66 2e 0f 1f 84 00 data16 cs nop WORD PTR [rax+rax*1+0x0]
c: 00 00 00 00
0000000000000010 <g>:
10: c3 ret
Testing on https://godbolt.org/ indicates this issue is present in all gcc
versions. clang emits correct code for this test case.
next reply other threads:[~2021-02-24 18:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-24 18:17 borysp at invisiblethingslab dot com [this message]
2021-02-24 18:58 ` [Bug tree-optimization/99258] " pinskia at gcc dot gnu.org
2021-02-25 8:19 ` [Bug middle-end/99258] " rguenth at gcc dot gnu.org
2021-02-25 9:15 ` 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-99258-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: link
Be 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).