public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105453] New: wrong choice of source in load instruction
@ 2022-05-02 14:48 absoler at smail dot nju.edu.cn
  2022-05-02 17:17 ` [Bug c/105453] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: absoler at smail dot nju.edu.cn @ 2022-05-02 14:48 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-07-07 10:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 14:48 [Bug c/105453] New: wrong choice of source in load instruction absoler at smail dot nju.edu.cn
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

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).