This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug inline-asm/33171] GCC outputs invalid assembly when using -O2



------- Comment #3 from pinskia at gcc dot gnu dot org  2007-08-24 09:02 -------
No, the inline-asm is just wrong, you need to use a different thing for
including non indexed load/stores.

The inline-asm function should be written as:
static inline unsigned long
load_acquire(volatile unsigned long *addr)
{
  unsigned long result;

  __asm__ __volatile__ (
    "lwz%X1 %0,%1\n"
    "cmpw cr7,%0,%0\n"
    "bne- cr7,1f\n"
    "1: isync\n"
    : "=r" (result)
    : "m"(*addr) : "memory", "cc");
  return result;
}

Though I will make a mention this is not really atomic at all.  You need to use
lwarx/stwcx to be atomic.  Also lwsync should be used instead of isync (IIRC).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33171


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]