From e3e0053fbe27a3c2e537f5ab5866aa620631d66f Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Wed, 24 Aug 2022 18:29:49 +0200 Subject: gcc: Enhance builtin_expect description --- src/development/gcc.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/development/gcc.md b/src/development/gcc.md index 88e44fc..39ae753 100644 --- a/src/development/gcc.md +++ b/src/development/gcc.md @@ -29,6 +29,10 @@ Give the compiler a hint which branch is hot, so it can lay out the code accordingly to reduce number of jump instructions. See on [compiler explorer](https://godbolt.org/z/MbTHAP). +The semantics of this hint are as follows, the compiler prioritises `expr == +cond`. So `__builtin_expect(expr, 0)` means that we expect the `expr` to be `0` +most of the time. + ```bash echo " extern void foo(); -- cgit v1.2.3