[PATCH] ifplugd: using the __builtin_expect?
Denys Vlasenko
vda.linux at googlemail.com
Thu Jul 8 20:48:28 UTC 2010
On Thursday 08 July 2010 15:32, Maksym Kryzhanovskyy wrote:
> > Denys Vlasenko wrote:
> > > > On Wednesday 07 July 2010 12:58, Maksym Kryzhanovskyy wrote:
> > > >
> > >> >> Hi Denis,
> > >> >>
> > >> >> can we use the __builtin_expect function in busybox?
> > >> >>
> > > > - if (!G.detect_link_func) {
> > > > + if (__builtin_expect(G.detect_link_func == NULL, 0)) {
> > > >
> > > > I don't see any changes in size, only obfuscated code.
> > > >
> > I think the main point of __builtin_expect is to make the code faster by
> > telling the compiler which branch is more likely, not to make the
> > assembly code smaller or easier to read.
> > Actually I would expect the above sequence to require an extra jump,
> > making the code bigger.
> >
> > Ralf
> >
>
> when we use the __builtin_expect in smaller code,
> the compiler adds a few extra instructions (the result
> should be slightly larger):
>
> if (detect_link_func == 0)
>
> testl %eax, %eax
> jne .L4
>
>
> if (__builtin_expect(detect_link_func == 0, 0))
>
> testl %eax, %eax
> sete %al
> movzbl %al, %eax
> testl %eax, %eax
> je .L4
Haha, wonderful. It does tha same thing, but is bigger AND slower...
> Is it intentionally turned off in busybox?
I guess -Os disables this optimization.
--
vda
More information about the busybox
mailing list