5 ms·
Another for the pro side: inlining can allow for better branch prediction if the different call sites would tend to drive different code paths in the function.
by a_e_k 2y ago
Another for the pro side: inlining can allow for better branch prediction if the different call sites would tend to drive different code paths in the function.
- phire 2y agoThis was true 15 years ago, but not so much today. The branch predictors actually hash the history of the last few branches taken into the branch prediction query. So the exact same branch within a child function will map different branch predictors entries depending on which parent function it was called from, and there is no benifit to inlining. It also means that branch predictor can also learn correlations between branches within a function. Like when a branches at the top and bottom of functions share conditions, or have inverted conditions.