public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/63375] New: reordering of reads across fences
@ 2014-09-25 23:08 bobby.prani at gmail dot com
  2014-09-25 23:11 ` [Bug rtl-optimization/63375] " bobby.prani at gmail dot com
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: bobby.prani at gmail dot com @ 2014-09-25 23:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63375

            Bug ID: 63375
           Summary: reordering of reads across fences
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bobby.prani at gmail dot com

A read within the region of code enclosed by barriers is being moved out of the
regions. Test case follows:

#include<stdio.h>

typedef struct {
    int counter;
} atomic_t;

static inline int atomic_read(atomic_t *v)
{
    return (*(volatile int *)&(v)->counter);
}

#define smp_mb() asm volatile ("mfence":::"memory")

int main()
{
    atomic_t val = {1};
    int p;

    smp_mb();
    p = atomic_read(&val);
    smp_mb();

    printf("%d\n", p);

    return 0;
}

Generated assembly:

  15:    mfence
  18:    mfence
  1b:    mov    $0x1,%esi
  20:    mov    $0x0,%rdi
  27:    xor    %eax,%eax
  29:    callq  2e <init_module+0x2e>


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

end of thread, other threads:[~2014-11-25 10:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-25 23:08 [Bug rtl-optimization/63375] New: reordering of reads across fences bobby.prani at gmail dot com
2014-09-25 23:11 ` [Bug rtl-optimization/63375] " bobby.prani at gmail dot com
2014-09-26  0:35 ` [Bug tree-optimization/63375] " pinskia at gcc dot gnu.org
2014-09-26  8:18 ` [Bug tree-optimization/63375] [4.8/4.9/5 Regression] " rguenth at gcc dot gnu.org
2014-10-01 14:49 ` jamborm at gcc dot gnu.org
2014-10-02 16:49 ` jamborm at gcc dot gnu.org
2014-10-02 17:12 ` jamborm at gcc dot gnu.org
2014-10-02 17:14 ` jamborm at gcc dot gnu.org
2014-10-09  9:04 ` jakub at gcc dot gnu.org
2014-10-10 11:13 ` rguenth at gcc dot gnu.org
2014-11-10 17:34 ` [Bug rtl-optimization/63375] " bobby.prani at gmail dot com
2014-11-24 13:34 ` rguenth at gcc dot gnu.org
2014-11-24 15:03 ` bobby.prani at gmail dot com
2014-11-24 15:19 ` jakub at gcc dot gnu.org
2014-11-24 16:12 ` rguenth at gcc dot gnu.org
2014-11-24 19:32 ` bobby.prani at gmail dot com
2014-11-25 10:15 ` mikpelinux at gmail dot com

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