Re:Size cost of C++ exception handling on embedded platforms
by haldean on Monday May 16, 2016 @12:43PM
(#11707552)
In C, there are ways you can get the optimizer to turn if-based error handling into something that only spends one or two instructions; using __builtin_expect[0] can decrease the cost of a condition by letting the branch predictor pick the "right" thing to expect. That way you end up only paying the price of the branch (and maybe the jump) instructions without any pipeline flushes or stalls.
[0]: http://blog.man7.org/2012/10/how-much-do-builtinexpect-likel...