public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "paulmckrcu at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/96327] New: Inefficient increment through pointer to volatile on x86 Date: Mon, 27 Jul 2020 01:47:08 +0000 [thread overview] Message-ID: <bug-96327-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96327 Bug ID: 96327 Summary: Inefficient increment through pointer to volatile on x86 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: paulmckrcu at gmail dot com Target Milestone: --- Although the code generation for increment (++, --) through a pointer to volatile has improved greatly over the past 15 years, there is a case in which the address calculation is needlessly done separately instead of by the x86 increment instruction itself. Here is some example code: struct task { int other; int rcu_count; }; struct task *current; void rcu_read_lock() { (*(volatile int*)¤t->rcu_count)++; } As can be seen in godbolt.org (https://godbolt.org/z/fGze8E), the address calculation is split by GCC. The shorter code sequence generated by clang/LLVM is preferable. Fixing this would allow the Linux kernel to use safer code sequences for certain fastpaths, in this example, rcu_read_lock() and rcu_read_unlock() for kernels built with CONFIG_PREEMPT=y.
next reply other threads:[~2020-07-27 1:47 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-27 1:47 paulmckrcu at gmail dot com [this message] 2020-07-27 1:56 ` [Bug c/96327] " paulmckrcu at gmail dot com 2020-07-27 2:05 ` [Bug target/96327] " pinskia at gcc dot gnu.org 2020-07-27 2:06 ` pinskia at gcc dot gnu.org 2020-07-27 3:26 ` paulmckrcu at gmail dot com 2020-07-30 19:03 ` glisse at gcc dot gnu.org 2020-07-30 19:23 ` paulmckrcu at gmail dot com
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-96327-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).