Hacker News new | ask | show | jobs
by Pazzaz 2601 days ago
What can the compiler actually do with '__builtin_expect_with_probability'? I understand that '__builtin_expect' can be used to choose which branch to prioritize but can you expect the optimizer to get better by having a probability attached?
1 comments

The compiler can choose which implementation to generate based on the actual expected performance gain in the happy case, the performance loss in the not happy case and use the probability to decide whether its actually worth the trade off