aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/development/gcc.md
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2022-08-24 18:29:49 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2022-08-24 18:30:00 +0200
commite3e0053fbe27a3c2e537f5ab5866aa620631d66f (patch)
tree6555c6c0382c63d530b90a6d57729caa10f2d302 /src/development/gcc.md
parent087e4222f1964de9fbef1b11f1344b0f93cefbe2 (diff)
downloadnotes-e3e0053fbe27a3c2e537f5ab5866aa620631d66f.tar.gz
notes-e3e0053fbe27a3c2e537f5ab5866aa620631d66f.zip
gcc: Enhance builtin_expect description
Diffstat (limited to 'src/development/gcc.md')
-rw-r--r--src/development/gcc.md4
1 files changed, 4 insertions, 0 deletions
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();