Boost logo

Boost :

Subject: Re: [boost] [review] **NEXT WEEK** Review of Outcome (starts Fri-19-May)
From: Marc Glisse (marc.glisse_at_[hidden])
Date: 2017-05-15 15:21:52

On Mon, 15 May 2017, Niall Douglas via Boost wrote:

> On 14/05/2017 12:33, Niall Douglas wrote:
>>>> But I can see a feature like __builtin_expect that going the way of the
>>>> dodo as the compiler vendors really would prefer if you used profile
>>>> guided optimisation instead. Passing that sort of micro-info from the
>>>> parser to the backend is surely complex to get right.
>>> I looked for bug reports about __builtin_expect in gcc's bugzilla, and
>>> the only relevant one I found was
>>> about using it in a
>>> switch. Could you back your statement with some links? Otherwise it
>>> sounds like FUD (at least the part about ignoring multiple persistent
>>> reports).
>> It's possible my memory is faulty, but I don't think it was. It was a
>> very good talk, basically a long list with extensive microdetail of how
>> compiler version quirks get in the way of micro optimisation. Builtin
>> expect was but one of many in a long list.
>> The presenter, Jason McGuiness, is one of the more colourful regular
>> attendees at ACCU and from all my interactions with him to date, I would
>> be considering him to not be FUDing. He's presented similar material at
>> ACCU London talks and several others.
>> His slides for the ACCU talk aren't online yet, so I'm sent him a
>> LinkedIn request and I'll ask for a copy. I'll post a link here if I get
>> them.
> Jason has provided a copy of the ACCU talk slides at


> Lots of graphs and assembler showing builtin_expect not working right on
> GCC.

Not really. There are only 2 mentions of __builtin_expect in those slides:
* switch expansion in gcc ignores __builtin_expect (that's the PR I
referenced above)
* an unclear benchmark about adding __builtin_expect in 1 place in some
unknown code, where __builtin_expect actually seems to help with the more
recent version of gcc.

No "inverting the code path you specifically told the compiler was the hot
path", no "multiple persistent reports", no "the feature is now useless on
GCC >= 5" (he actually writes "Newer versions of g++ make better use of
optimization" though that's not specifically about __builtin_expect), no
"The speaker recommended clang, especially very recent clang" ("No one
compiler appears to be best - choice is crucial. Newest versions of clang
have not been investigated.")

The vocabulary in the slides is odd (any memory is called stack, anything
64 bits is called SSE) and there are some questionable statements. Taking
a gcc dev point of view, the main information I got form those slides is
interest in PR 59521 and some small margin of progress on copying constant

If anything, the section on static branch prediction advertises that one
should use __builtin_expect more ;-)

Marc Glisse

Boost list run by bdawes at, gregod at, cpdaniel at, john at