Medium
A branch that's almost always taken
fastPath and slowPath are both moderately large, and in the real production workload the condition is true about 99.9% of the time, which nothing in the source reveals. Compare a plain -O2 build with a PGO build (profile collected from representative traffic, then fed back into a second compilation). What changes?
main.cpp
int fastPath(int x); // large-ish function bodies, cost borderline for inlining
int slowPath(int x);
int dispatch(int x, bool condition) {
if (condition) {
return fastPath(x);
} else {
return slowPath(x);
}
}25 of 44 in Compilers