]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: compiler: drop special cases of likely/unlikely for older compilers
authorWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 06:14:43 +0000 (07:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 06:29:55 +0000 (07:29 +0100)
commit89ee79845cf2a82c47a6560644773ef8b70eef77
tree5185a15845263e2cb8800cf27ca047b1b2d5d912
parent3f25ae31bdc0e7a178e75e2cd08e8deb6bfe101e
MINOR: compiler: drop special cases of likely/unlikely for older compilers

We used to special-case the likely()/unlikely() macros for a series of
early gcc 4.x compilers which used to produce very bad code when using
__builtin_expect(x,1), which basically used to build an integer (0 or 1)
from a condition then compare it to integer 1. This was already fixed in
5.x, but even now, looking at the code produced by various flavors of 4.x
this bad behavior couldn't be witnessed anymore. So let's consider it as
fixed by now, which will allow to get rid of some ugly tricks at some
specific places. A test on 4.7.4 shows that the code shrinks by about 3kB
now, thanks to some tests being inlined closer to the call place and the
unlikely case being moved to real functions. See the link below for more
background on this.

Link: https://www.mail-archive.com/haproxy@formilux.org/msg36392.html
include/common/compiler.h