Re: [PATCH] ifplugd: using the __builtin_expect?

Maksym Kryzhanovskyy xmaks at email.cz
Thu Jul 8 12:44:21 UTC 2010


On 08.7.2010 11:02:10, Maksym Kryzhanovskyy wrote:
> On 08.7.2010 02:37:35, Denys Vlasenko wrote:
> > On Wednesday 07 July 2010 12:58, Maksym Kryzhanovskyy wrote:
> > > Hi Denis,
> > > 
> > > can we use the __builtin_expect function in busybox?
> > > In the previous patch for ifplugd it might be usefull
> > > (see attachment).
> > 
> > -       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.
> 

.. you're right it is for nothing, detect_link with __builtin_expect
 is the same as without it. It is seen from the code in attachment.

> 
> Yes, it's not for reducing the size of ifplugd, but we wanted to ask gcc to
> optimize the if statment for a negative result (moreover, it costs nothing in
> terms of size):
> 
> if (!G.detect_link_func) { // predominantly negative throughout life of ifplugd
> 
> 
> This may be unlikely() if it is more readable as Marek Polacek
> and Bernhard Fischer-Reutner offers:
> 
> #define unlikely(x) __builtin_expect(!!(x), 0)
> if (unlikely(G.detect_link_func == NULL)) {
> 
> 
> If it is actually needed..
> 
> 
> Max.
> 
> > -- 
> > vda
> > 
> > 
> > 
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: detect_link.s
Type: text/plain charset=us-ascii
Size: 1208 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20100708/127ca8b3/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: detect_link.unlikely.s
Type: text/plain charset=us-ascii
Size: 1208 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20100708/127ca8b3/attachment-0001.bin>


More information about the busybox mailing list