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

--- Comment #6 from Oleg Endo <olegendo at gcc dot gnu.org> ---
With r218705 on SH (-O2 -m4 -ml) I get the following:

unsigned short test_099 (unsigned short a, unsigned short b)
{
  return (((a & 0xFF00) >> 8) | ((a & 0xFF) << 8));
}

compiles to:
        extu.w    r4,r4
        rts
        swap.b    r4,r0


unsigned short test_08 (unsigned short a, unsigned short b)
{
  return b + (((a & 0xFF00) >> 8) | ((a & 0xFF) << 8));
}

compiles to:
        extu.w  r4,r4
        mov     r4,r0
        shll8   r4
        shlr8   r0
        or      r0,r4
        add     r4,r5
        rts
        extu.w  r5,r0


Byte swapping of signed short types seems to be not working:

short test_func_111 (short a, short b, short c)
{
  return (((a & 0xFF00) >> 8) | ((a & 0xFF) << 8));
}

        exts.w  r4,r4
        mov     r4,r0
        shlr8   r0
        extu.b  r0,r0
        shll8   r4
        or      r0,r4
        rts
        exts.w  r4,r0

Reply via email to