These attributes allow the compiler to optimize for the case where paths of execution including these statements are more or less likely than other alternative paths. This can be used if the developer knows which lines of code would most probably be executed during code execution to help the compiler increase optimization for faster execution.
if (a > b) [[likely]] {
do_something();
} else {
do_other();
}
while (a > 0) {
[[unlikely]] g();
}
switch (x) {
case one:
f();
break;
case two:
[[likely]] g()İ
break;
default:
h();
}