How to understand macro `likely` affecting branch prediction?
问题 I noticed if we know there is good chance for control flow is true or false, we can tell it to compiler, for instance, in Linux kernel, there are lots of likely unlikely , actually impled by __builtin_expect provided by gcc , so I want to find out how does it work, then checked the assembly out there: 20:branch_prediction_victim.cpp **** if (array_aka[j] >= 128) 184 .loc 3 20 0 is_stmt 1 185 00f1 488B85D0 movq -131120(%rbp), %rax 185 FFFDFF 186 00f8 8B8485F0 movl -131088(%rbp,%rax,4), %eax