摘自
ARM System Developer’s Guide
Designing and Optimizing System Software
中文版
英文版的免费下载地址:
http://www.docstoc.com/docs/2844296/ARM-System-Developers-Guide
需要注册一下
Summary Writing Loops Efficiently■ Use loops that count down to zero. Then the compiler does not need to allocate
a register to hold the termination value, and the comparison with zero is free.
■ Use unsigned loop counters by default and the continuation condition i!=0 rather than
i>0. This will ensure that the loop overhead is only two instructions.
■ Use
do-while loops rather than
for loops when you know the loop will iterate at least
once. This saves the compiler checking to see if the loop count is zero.
■ Unroll important loops to reduce the loop overhead. Do not overunroll. If the loop
overhead is small as a proportion of the total, then unrolling will increase code size and
hurt the performance of the cache.
■ Try to arrange that the number of elements in arrays are multiples of four or eight. You
can then unroll loops easily by two, four, or eight times without worrying about the
leftover array elements.
文章评论(0条评论)
登录后参与讨论