Hi,

2011/12/15 Måns Rullgård <[email protected]>

> "Ronald S. Bultje" <[email protected]> writes:
>
> > Hi,
> >
> > 2011/12/15 Måns Rullgård <[email protected]>
> >
> >> "Ronald S. Bultje" <[email protected]> writes:
> >>
> >> > +#   define SKIP_COUNTER(name, gb, num) name##_index = \
> >> > +               (gb)->size_in_bits_plus1 - name##_index < (num) ? \
> >> > +               (gb)->size_in_bits_plus1 : name##_index + (num)
> >>
> >> BTW, does index += FFMIN(num, size_in_bits_plus1 - index) generate worse
> >> code, or did you just not like the look of it?
> >
> > Generates the same code on x86. Is it better on arm? I don't mind either
> > way.
>
> I think it looks nicer.
>

I take it back, old gcc-4.2 (Mac) barf on it...

FFMIN (17 instructions):
0x0000000100310220 <get_bits+0>: mov    %edi,%eax
0x0000000100310222 <get_bits+2>: shr    $0x3,%eax
0x0000000100310225 <get_bits+5>: mov    %eax,%eax
0x0000000100310227 <get_bits+7>: mov    (%r10,%rax,1),%esi
0x000000010031022b <av_bswap32+0>: bswap  %esi
0x000000010031022d <get_bits+13>: mov    %edi,%ecx
0x000000010031022f <get_bits+15>: and    $0x7,%ecx
0x0000000100310232 <get_bits+18>: shl    %cl,%esi
0x0000000100310234 <NEG_USR32+0>: shr    $0xfe,%esi
0x0000000100310237 <get_bits+23>: mov    %r8d,%eax
0x000000010031023a <get_bits+26>: sub    %edi,%eax
0x000000010031023c <get_bits+28>: cmp    $0x2,%eax
0x000000010031023f <get_bits+31>: mov    $0x2,%edx
0x0000000100310244 <get_bits+36>: cmova  %edx,%eax
0x0000000100310247 <get_bits+39>: lea    (%rax,%rdi,1),%ecx
0x000000010031024a <get_bits+42>: mov    %ecx,%edi
0x000000010031024c <get_bits+44>: mov    %ecx,0x1768(%rbx)

current patch (15 instructions):
0x000000010030fefb <get_bits+0>: mov    %edx,%eax
0x000000010030fefd <get_bits+2>: shr    $0x3,%eax
0x000000010030ff00 <get_bits+5>: mov    %eax,%eax
0x000000010030ff02 <get_bits+7>: mov    (%r8,%rax,1),%r10d
0x000000010030ff06 <av_bswap32+0>: bswap  %r10d
0x000000010030ff09 <get_bits+14>: mov    %esi,%ecx
0x000000010030ff0b <get_bits+16>: shl    %cl,%r10d
0x000000010030ff0e <NEG_USR32+0>: shr    $0xfe,%r10d
0x000000010030ff12 <get_bits+23>: mov    %edi,%esi
0x000000010030ff14 <get_bits+25>: mov    %edi,%eax
0x000000010030ff16 <get_bits+27>: sub    %edx,%eax
0x000000010030ff18 <get_bits+29>: add    $0x2,%edx
0x000000010030ff1b <get_bits+32>: cmp    $0x2,%eax
0x000000010030ff1e <get_bits+35>: cmovae %edx,%esi
0x000000010030ff21 <get_bits+38>: mov    %esi,0x1768(%rbx)

unsafe bitstream reader (12 instructions - note lack of mov/cmovae/cmp):
0x00000001003022d0 <get_bits+0>: mov    %esi,%edx
0x00000001003022d2 <get_bits+2>: mov    %esi,%eax
0x00000001003022d4 <get_bits+4>: shr    $0x3,%eax
0x00000001003022d7 <get_bits+7>: mov    %eax,%eax
0x00000001003022d9 <get_bits+9>: mov    (%rdi,%rax,1),%eax
0x00000001003022dc <av_bswap32+0>: bswap  %eax
0x00000001003022de <get_bits+14>: mov    %esi,%ecx
0x00000001003022e0 <get_bits+16>: and    $0x7,%ecx
0x00000001003022e3 <get_bits+19>: shl    %cl,%eax
0x00000001003022e5 <NEG_USR32+0>: shr    $0xfe,%eax
0x00000001003022e8 <get_bits+24>: lea    0x2(%rdx),%esi
0x00000001003022eb <get_bits+27>: mov    %esi,0x1768(%rbx)

So maybe I'll keep it. Not sure why it barfs, silly gcc...

Ronald
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to