public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "absoler at smail dot nju.edu.cn" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-105453-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105453 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=52917&action=edit concurrent case Here's the code: int g_6[2] = {0x67D50F82L,0x67D50F82L}; int g_10 = 0L; int func_1(void) { int *l_9 = &g_10; (*l_9) = (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 <g_6> 0x0000000000401153 <+6>: mov %eax,0x2ef3(%rip) # 0x40404c <g_10> 0x0000000000401159 <+12>: cmpl $0x0,0x2ee4(%rip) # 0x404044 <g_6+4> 0x0000000000401160 <+19>: mov $0x1,%eax 0x0000000000401165 <+24>: cmovne 0x2ed4(%rip),%eax # 0x404040 <g_6> 0x000000000040116c <+31>: retq yes, it assert that g_10 = 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.
next reply other threads:[~2022-05-02 14:48 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-02 14:48 absoler at smail dot nju.edu.cn [this message] 2022-05-02 17:17 ` [Bug c/105453] " pinskia at gcc dot gnu.org 2022-05-02 17:18 ` pinskia at gcc dot gnu.org 2022-05-02 22:31 ` [Bug rtl-optimization/105453] load introduced by ce1 for conditional loads at -O1, might cause issues with the C/C++ memory model pinskia at gcc dot gnu.org 2022-05-03 6:45 ` rguenth at gcc dot gnu.org 2022-05-03 6:46 ` [Bug rtl-optimization/105453] [9/10/11 Regression] " rguenth at gcc dot gnu.org 2022-05-03 7:24 ` redi at gcc dot gnu.org 2022-05-27 9:48 ` [Bug rtl-optimization/105453] [10/11 " rguenth at gcc dot gnu.org 2022-06-28 10:49 ` jakub at gcc dot gnu.org 2023-07-07 10:43 ` [Bug rtl-optimization/105453] [11 " rguenth 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-105453-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).