Sep 20, 2008They are hint to the compiler to emit instructions that will cause branch prediction to favour the "likely" side of a jump instruction.Using Likely() / Unlikely() Preprocessor Macros in if-else if chainCan likely/unlikely macros be used in user-space code?c++ - Simple example where [[likely]] and [[unlikely]] affect program Why doesn't likely and unlikely macros have any effect on ARM More results from stackoverflow.com
Sep 20, 2008They are hint to the compiler to emit instructions that will cause branch prediction to favour the "likely" side of a jump instruction.Using Likely() / Unlikely() Preprocessor Macros in if-else if chaingcc likely() unlikely() macros and assembly code - Stack Overflowc++ - Simple example where [[likely]] and [[unlikely]] affect program learning sample of likely() and unlikely() compiler hintsMore results from stackoverflow.com
Use of the unlikely macro allows the compiler to optimize by removing an instruction from the likely path. From the above comparison, we see that the compiler has removed on instruction from the likely path — xor eax, eax .