From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 972B83858D3C; Mon, 2 May 2022 14:48:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 972B83858D3C From: "absoler at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/105453] New: wrong choice of source in load instruction Date: Mon, 02 May 2022 14:48:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: absoler at smail dot nju.edu.cn 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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, 02 May 2022 14:48:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105453 Bug ID: 105453 Summary: wrong choice of source in load instruction Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: absoler at smail dot nju.edu.cn Target Milestone: --- Created attachment 52917 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52917&action=3Dedit concurrent case Here's the code: int g_6[2] =3D {0x67D50F82L,0x67D50F82L}; int g_10 =3D 0L; int func_1(void) {=20 int *l_9 =3D &g_10; (*l_9) =3D (g_6[0]); if (g_6[1]) { return g_10; } return 1; } and on gcc-11.3.0 with -O1 option, the assembly code are as follows: 0x000000000040114d <+0>: mov 0x2eed(%rip),%eax # 0x404040 0x0000000000401153 <+6>: mov %eax,0x2ef3(%rip) # 0x40404c 0x0000000000401159 <+12>: cmpl $0x0,0x2ee4(%rip) # 0x404044 0x0000000000401160 <+19>: mov $0x1,%eax 0x0000000000401165 <+24>: cmovne 0x2ed4(%rip),%eax # 0x404040 0x000000000040116c <+31>: retq yes, it assert that g_10 =3D g_6[0] and this may cause problem in concurrent environment. The case files uploaded can show that the generated code is the same as above in an environment that g_6 may be modified by other thread.=