Skip to content
Search

GCC: builtin expect

lastmod 2018-08-17created 2018-04-033 edits

In short, it is a macro that makes the compiler optimize for the code most likely to run.

Defensive coding means adding countless if statements, and anyone who has studied architecture even a little shies away from if statements because of pipeline hazards. You cannot remove the harm of an if statement, but this keyword lets you place the code most likely to execute below it, minimizing pipeline hazards.

See also

Favorite site