Is there any portable way of doing branch prediction hints? Consider the following example:
if (unlikely_condition) {
/* ..A.. */
} else {
/* ..B.. */
}
Is this any different than doing:
if (!unlikely_condition) {
/* ..B.. */
} else {
/* ..A.. */
}
Or is the only way to use compiler specific hints? (e.g. __builtin_expect on GCC)
Will compilers treat the if
conditions any differently based on the ordering of the conditions?