利用移位运算 加速乘法

Practice Problem 2.21:


As we will see in Chapter 3, the leal instruction on an Intel-compatible processor can perform computations
of the form a< The compiler often uses this instruction to perform multiplications by constant factors. For example, we
can compute 3*a as a<<1 + a.
What multiples of a can be computed with this instruction?

 

因为加法和移位运算只要一个指令时间,所以快很多

你可能感兴趣的:(深入理解计算机系统笔记)