On Sun, 14 May 2017, Niall Douglas via Boost wrote:
There was a very interesting talk at ACCU (unfortunately in the non-videoed room) by a HFT guy explaining all the ways in which recent GCC versions have bugged __builtin_expect, like inverting the code path you specifically told the compiler was the hot path.
GCC devs apparently don't care enough to fix it despite multiple persistent reports, and the feature is now useless on GCC >= 5. The speaker recommended clang, especially very recent clang which is apparently finally being competitive with GCC in generating very tight code. I'd back that up, clang 5.0 is generating much tighter code with Outcome than clang 3.x did, markedly so.
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 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59521 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). -- Marc Glisse