From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 365A43858D38; Mon, 27 Jul 2020 01:56:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 365A43858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1595814978; bh=bkbUOukj7Lk7v+mhRTMmW0TUm2LsBy0fp5HYw0eK2HE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dmJw1gmwvq1qpYLjijGwA6uVKSqfv3ZEBrPhZwmisWPhyZb6vjn2764S94Q62nXD3 jUdJRk+Kbp120lhRDeLoRFMX82PVgrdbN8UXXiZvbFmNWAh/rom2GaMsn1CSScY2oM YOjxymUxR1MzpD/G9ZGo5trZWg7UGEKu158vO+6k= From: "paulmckrcu at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/96327] Inefficient increment through pointer to volatile on x86 Date: Mon, 27 Jul 2020 01:56:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: paulmckrcu at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jul 2020 01:56:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96327 --- Comment #1 from Paul McKenney --- This manifests on GCC trunk (see the godbolt.org URL), but was first noted = in gcc version 7.5.0. This is specific to x86, but might apply to any other architecture that provides increment-memory instructions. This behavior do= es not seem to be affected by GCC options. This can be reproduced by placing the sample code in a file "rrl.c" and running: cc -o rrl rrl.c This completes successfully with no error or warnings. Running "cc -o rrl rrl.c --save-temps" generates the following file: # 1 "rrl.c" # 1 "" # 1 "" # 31 "" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 32 "" 2 # 1 "rrl.c" struct task { int other; int rcu_count; }; struct task *current; void rcu_read_lock() { (*(volatile int*)¤t->rcu_count)++; }=