News for hackers. Stuff that matters.
Re:Branch predictor: How many “if”s are too many? by knorker on Thursday May 06, 2021 @06:39PM (#27069829)
You can hint the compiler: https://en.cppreference.com/w/cpp/language/attributes/likely

Or you can use profile directed optimization, as others mentioned.

In my test recently it reduced branches as a whole by 30%, according to perf stat ./a.out

There are no comments on this comment yet.