2 ms·
Would gcc's "__builtin_expect" construct help in these cases?
by rzzzt 9y ago
Would gcc's "__builtin_expect" construct help in these cases?
- syncsynchalt 9y agoYes, it might have, assuming it's available in the 360 compilation environment. Another solution would be to split the existing function into safe_function() and unsafe_function(), and remove use of the PREFETCH_EX flag. But then you have to explain to callers that they must not protect calls to unsafe_function() with any kind of conditional statement. The author hinted at possible solutions but it was probably a case of "twice bitten" by that point.
- tmandry 9y agoIn general, no, because branch predictors often ignore or override hints like this. It's hard to say without knowing this architecture specifically, of course. Keep in mind that it's possible for a branch predictor to predict with "high confidence" a branch it's never seen before, because many branches may overlap into the same memory region of the predictor. The article touches on this.