At one of our meetings Erick asked for guidelines for x86 assembly coding for best performance. I just found a set of references which address that question in depth.
http://www.agner.org/optimize/
In particular I suggest that people read the following manual:
http://www.agner.org/optimize/optimizing_assembly.pdf
which is specifically about x86 assembly coding and contains very up to date information (for example, the nehalem and sandy bridge processors).
Here's an interesting passage which supports my view that the code size is an important issue because it affects the efficiency of the caches and BTB (branch target buffer):
18.2 The pitfalls of unit-testing
If you want to find out which version of a function performs best then it is not sufficient to measure clock cycles in a small test program that calls the function many times. Such a test is unlikely to give a realistic measure of cache misses because the test program may use less memory than the cache size. For example, an isolated test may show that it is advantageous to roll out a loop while a test where the function is inserted in the final program shows a large amount of cache misses when the loop is rolled out.
Therefore, it is important not only to count clock cycles when evaluating the performance of a function, but also to consider ***how much space it uses in the code cache, data cache and branch target buffer.***
In other words, the code compactness of fib is probably not much of an issue when fib is run by itself, but it may be a problem if it is part of a larger program which also does other calculations.
The manual contains many more guidelines. Please read it, if not in detail, at least browse it to know what the issues are.
Marc
Afficher les réponses par date