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

--- Comment #13 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #1)
> (In reply to Oleg Endo from comment #0)
> > The following example is taken from libav, which contains quite some uses of
> > this code pattern.
> > 
> > typedef unsigned short int uint16_t;
> > union unaligned_16 { uint16_t l; } __attribute__((packed));
> > 
> > int
> > test (unsigned char* buf, int bits_per_component)
> > {
> >   (((union unaligned_16 *)(buf))->l) =
> >     __builtin_bswap16 (bits_per_component == 10 ? 1 : 0);
> > 
> >   return 0;
> > }
> > 
> 
> BTW, it should actually translate to something like:
> 
>       mov     r6,r0
>       cmp/eq  #10,r0
>       movt    r0
>       mov.b   r0,@(1,r4)
>       mov     #0,r0
>       rts
>       mov.b   r0,@r4
> 

It's pretty much what GCC 13 produces (with -mlra -ml)

        mov     r5,r0           ! 51    [c=4 l=2]  movsi_i/1
        cmp/eq  #10,r0          ! 48    [c=4 l=2]  cmpeqsi_t/1
        movt    r0              ! 49    [c=4 l=2]  movt
        mov     #0,r1           ! 11    [c=4 l=2]  movsi_i/2
        mov.b   r0,@(1,r4)      ! 29    [c=4 l=2]  *movqi_store_mem_disp04/0
        mov     #0,r0           ! 34    [c=4 l=2]  movsi_i/2
        rts                     ! 55    [c=0 l=2]  *return_i
        mov.b   r1,@r4          ! 18    [c=4 l=2]  *movqi/5

Reply via email to