4 ms·
As a coder, how can I predict the branch predictor?
by marshray 14y ago
As a coder, how can I predict the branch predictor?
- CamperBob2 14y agoThere are definite rules, documented by the CPU vendor. A forward branch is assumed not taken, while a backward branch is assumed to come at the end of a loop that will probably iterate more than once. See http://software.intel.com/en-us/articles/branch-and-loop-reorganization-to-prevent-mispredicts/ http://software.intel.com/en-us/articles/branch-and-loop-reo... for example. I'd assume the particulars will vary between CPU manufacturers and families, but the idea that backward branches will probably be taken seems fairly universal.
- haberman 14y agoThis is outdated information; Intel chips have not used static prediction for conditional branches since NetBurst (Pentium 4). "Pentium M, Intel Core Solo and Intel Core Duo processors do not statically predict conditional branches according to the jump direction. All conditional branches are dynamically predicted, even at first appearance." --http://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-optimization-manual.pdf http://www.intel.com/content/dam/doc/manual/64-ia-32-archite...