Changes between Version 1 and Version 2 of BackEndNotes

Aug 8, 2006 4:48:50 PM (11 years ago)

mention branch prediction


  • BackEndNotes

    v1 v2  
    9797    into the above code (apparently gcc can do this).
     99== Framework for branch prediction ==
     101On modern CPUs correctly predicted branches are nearly free while mis-predicted branches incurr quite a high penalty due to pipeline stalls etc.
     103There are a number of low level things that can be done if we have some idea of the probability of a branch being taken. For example the block corresponding to the branch that is unlikely to be taken can be made the target of the jump so that the fall through branch is the likely one. On some CPUs its possible to add explicit hints to conditional jump instructions. If a branch is comparatively very unlikely then its block can be moved completely out of line. See a CPU architecture/optimisation guide for more suggestions.
     105GCC has a framework for gathering and using branch prediction information to improve code generation. It can get information from a static analysis and heuristics, from profile feedback and ffrom explicit user annotations via __builtin_expect().
     107So the suggestion is that GHC could have a similar framework including explicit user annotations. It is believed that this could make a significant difference to the speed of some low level code like ByteString.
     109See ticket #849 for more details.
    99111== Improving and refactoring the native code generator ==