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

--- Comment #13 from Oleg Endo <olegendo at gcc dot gnu.org> ---
BTW, using the "m" constraint for QImode and HImode in inline asm is dangerous.
 It's very easy to create wrong code with it.  For example:

struct test_struct
{
  unsigned short a, b, c, d;
};

void test (struct test_struct* s, unsigned short* result)
{
  unsigned short r;

  __asm__ __volatile__ (
    "mov.w    %1,%0"
    : "=&r" (r)
    : "m" (s->b)
    : "memory");

  *result = r;
}

will compile to:

_test:
! 39 "sh_tmp.cpp" 1
        mov.w   @(2,r4),r1    ! Invalid mov.w for non-SH2A.
! 0 "" 2
        rts
        mov.w   r1,@r5


I think in order to avoid surprises and simplify debugging of such code
something like the patch in comment #11 should be added to trunk.

Reply via email to