https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64306
Oleg Endo <olegendo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-02-22
Ever confirmed|0 |1
--- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> ---
When storing bswapped values to unaligned mems the following happens:
union unaligned32s { int val; } __attribute__((packed));
void store_32s_0 (unsigned char* x, unsigned char a, int b)
{
((union unaligned32s*)(x))->val = a;
}
mov #0,r0
extu.b r5,r5
mov.b r0,@(1,r4)
mov.b r0,@(2,r4)
mov r5,r0 // r0 = zero (redundant load)
shlr16 r0 // 0 >> 16 (redundant shift)
mov.b r5,@r4
shlr8 r0 // 0 >> 8 (redundant shift)
rts
mov.b r0,@(3,r4)
should be:
mov.b r5,@r4
mov #0,r0
mov.b r0,@(1,r4)
mov.b r0,@(2,r4)
mov.b r0,@(3,r4)
void store_32s_1 (unsigned char* x, unsigned char a, int b)
{
((union unaligned32s*)(x))->val = __builtin_bswap32 (a);
}
extu.b r5,r5
swap.b r5,r5
swap.w r5,r5
extu.b r5,r1
mov.b r1,@r4
mov #0,r1
mov r1,r0
mov.b r0,@(1,r4)
mov.b r0,@(2,r4)
mov r5,r0
shlr16 r0
shlr8 r0
rts
mov.b r0,@(3,r4)
should be:
mov #0,r0
mov.b r0,@(0,r4)
mov.b r0,@(1,r4)
mov.b r0,@(2,r4)
mov r5,r0
mov.b r0,@(3,r4)
A similar thing happens when storing the T bit to unaligned mems, see also PR
65162.