Industry prediction: Branch squad vs builtin_expect

I am learning about branch prediction C++

and have a pretty simple question.

The term seems to tell the compiler which clause to put into the assembly code first. __builtin_expect

However, if this is manually added by the programmer, how is it different than just toggling if / else clauses in the code C++

?

+3


source to share


1 answer


The compiler optimizer allows you to reorder branches. __builtin_expect is useful if the compiler gets (or most likely) gets it wrong.



+1


source







All Articles