[GHC] #9350: Consider using xchg instead of mfence for CS stores

GHC ghc-devs at haskell.org
Wed Jul 23 11:48:59 UTC 2014


#9350: Consider using xchg instead of mfence for CS stores
-------------------------------------+-------------------------------------
              Reporter:  tibbe       |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.9
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Easy (less than 1
  Unknown/Multiple                   |  hour)
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by tibbe):

 GCC 4.9.1 does use `mfence`. This code

 {{{
 #include <stdatomic.h>

 void f(atomic_int* obj, int val) {
   return atomic_store(obj, val);
 }
 }}}

 generates this assembly

 {{{
         .file   "repro.c"
         .text
         .globl  f
         .type   f, @function
 f:
 .LFB0:
         .cfi_startproc
         movl    %esi, (%rdi)
         mfence
         ret
         .cfi_endproc
 .LFE0:
         .size   f, .-f
         .ident  "GCC: (GNU) 4.9.1"
         .section        .note.GNU-stack,"", at progbits
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9350#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list