|
Integer Multiply Optimization
On many architectures, integer multiply instructions are slower than other instructions such as integer add and shift, and multiply expressions with power-of-two constant multiplicands and other bit patterns can be replaced with faster instructions. Example:The integer multiply expression in the code fragment below can be replaced with an shift expression.
int f (int i)
{
return i * 4;
}
Below is the code fragment after the multiply expression has been translated to a shift expression.
int f (int i)
{
return i << 2;
}
© 1990-2012 Nullstone Corporation. All Rights Reserved. |